Sunday, January 17, 2010

Compiling from Source Using APT

Most of us Ubuntu fans are pretty proficient with apt-get for installing binary packages. However, not that many of us use apt to download the source code for our favorite programs and compile them ourselves.

Using apt to download source code is pretty easy, and makes the problem of missing-dependencies all but disappear.

You can use the following to download the source code for any package (note: the source flag to apt will download the source code to your current working directory):

mkdir packagename
cd packagename
apt-get source packagename


While this downloads the source code for the package, it does not automatically download the libraries required to compile the source. To do that, use the following command:
apt-get build-dep packagename


Finally, you can do the standard configure/make/make install procedure inside of the packagename directory.


./configure
make
make install