Compiling Software – How to Compile and Install Programs from Source

compilingsoftware installationsource

This is an issue that really limits my enjoyment of Linux. If the application isn't on a repository or if it doesn't have an installer script, then I really struggle where and how to install an application from source.

Comparatively to Windows, it's easy. You're (pretty much) required to use an installer application that does all of the work in a Wizard. With Linux… not so much.

So, do you have any tips or instructions on this or are there any websites that explicitly explain how, why and where to install Linux programs from source?

Best Answer

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.

Related Question