5

To install software on a Linux system, many tools like yum, apt-get, rpm, dpkg and so on are available to either fetch a package from a repository or install a downloaded package.

Alternatively, it is possible to download a (typically) .tar.gz2 archive of the source and compile manually using

./configure
make
make install

or similar. My question is: When should one compile and install from source?

4 Answers4

5

In general it is recommend to use the packages coming by your distribution and using the related package manager (e.g.dpkg/apt-get on Debian-based system). The task of your distribution is to package software and to configure it such that there are no conflicts.

Sometimes your distribution does not have the software you want or you have other reasons like e.g.

  • you need a newer version
  • you want to have a special configuration or want to include patches etc.
  • you need more performance and therefore want to optimize the software especially for your hardware (processor, ...)

because you want to compile the software yourself (which can be become quite difficult - especially if you do not know all dependencies).

You have then different options:

  • rebuild it from the source, usually from a tarball (= *.tar.gz file) or from an upstream source repository like github
  • download/install a corresponding pre-built package (directly or by using an unofficial repository)
  • use the existing package source from your distribution, update it by hand and create a new package which you then can install.

If you install software not using the package manager, it is strongly recommended to install the software to other places than the package manager use. The destined prefix is /usr/local/. Installing into a new subdirectory of /opt or somewhere in your home folder are also options.

jofel
  • 26,758
4

I would say, compile from source only when you have to. When managing a system, losing the management facilities of your package manager can be something that should be avoided at all costs.

Often times I'll take a source package and build it and/or rebuild it from source but do it using the facilities provided to developers of packages for your distros package manager.

Example

Often I'll download a source RPM for a Redhat based distro and then modify it using the newer tarball of a given package and then rebuild it like so:

$ rpmbuild --rebuild some.package.src.rpm

Once rebuilt, I'll install it using yum or rpm.

References

slm
  • 369,824
  • Good answer in that you tell how to install from source reliably, but unfortunately you do not elaborate much on what situation I would need to compile from source. +1 for elaboration on what to do for source, though. – Davidson Chua Dec 04 '13 at 15:31
2

You should compile and install from source if your distribution's package does not suit your needs. For example, if you need to add an option not compiled in the package, or if you need to change a path to link to a particular library. Or if you need the latest version which is not packaged yet.

Vinz
  • 2,150
  • 14
  • 16
1

Short answer: when you need to.

Long answer: Most distributors offer precompiled packages of the most common used software in their repositories. First, compiling can be very painful for beginner users. Secondly, the distributor can assume that all systems have the same binaries that makes the distribution more stabile. Those precompiled packages run through a very hard test phase (depends on the distributor and release), before they are released in the repo. So I highly recommend to use the software sources from your distribution, before compiling by yourself. If there is no other way or the package is not available in the software sources and there is no other software that offers the same, you can compile from hand.

chaos
  • 48,171