How to compile and install programs from source

Normally, the project will have a website with instructions for how to build and install it. Google for that first.

For the most part you will do either:

  1. Download a tarball (tar.gz or tar.bz2 file), which is a release of a specific version of the source code
  2. Extract the tarball with a command like tar zxvf myapp.tar.gz for a gzipped tarball or tar jxvf myapp.tar.bz2 for a bzipped tarball
  3. cd into the directory created above
  4. run ./configure && make && sudo make install

Or:

  1. Use git or svn or whatever to pull the latest source code from their official source repository
  2. cd into the directory created above
  3. run ./autogen.sh && make && sudo make install

Both configure and autogen.sh will accept a --prefix argument to specify where the software is installed. I recommend checking out Where should I put software I compile myself? for advice on the best place to install custom-built software.


I just want to add that there are package managers that compile packages from source, and handle all package dependencies, flags, etc..

In BSD systems it's ports: Using the Ports Collection

In Debian, the apt-get package manager can install from source too: APT HOWTO: Working with source packages (Same goes for Ubuntu, Linux-mint and everything else based on Debian)

The Gentoo distribution uses the portage package manager, which compiles the whole system from source only: Portage Introduction.

Slackware can compile packages but I don't know if there's any package manager for this in there.. =)

Anyway you can always compile packages manually like Sandy mentioned above =) Also it must be possible to use apt-get or portage package managers in any other distro...


I think it's just best to read the documentation coming with that specific program or application that you're wanting to install. Usually there are readmes/READMEs inside the tarballs (the application source archive which you can usually download) or maybe even INSTALL files to read and learn about what is the preferred way of installing said application. In short: RTFM ;)