Saturday 24 May 2008

Using apt-get to compile from source

Compiling from source is something that strikes terror into the heart of every Linux newbie - it seems like such a black art. The usual trinity of /.configure, make and make install is something barely comprehensible if you're new to Linux. But you can relax - you almost never have to compile from source in Ubuntu as the repositories are very comprehensive.
Nonetheless, compiling from source has a place in every good Linux user's toolkit. It can result in better performance if you compile a CPU-intensive app from source. Distros like Gentoo enable you to get an entire system that's compiled specifically to get the absolute best out of your hardware.
The Debian package manager used by Ubuntu offers an interesting compromise that allows you to easily compile apps from source. It doesn't get you the kudos that compiling from source will normally give you, but it's easy to use and is well within the capability of a relative newbie. It also creates a .deb package so it's easy to uninstall if necessary.
We'll compile the Dillo web browser in this example. The process is different to how you'd install software using apt-get normally. Before anything else, make sure you open Synaptic (or Adept if you're using Kubuntu) and check the box to include the source code repositories.
Once that's done, we can get on with the installation. First, you have to install the dependencies:
sudo apt-get build-dep dillo

This installs all the dependencies needed to compile Dillo. Next, you need to tell apt-get to download and compile the source code:
sudo apt-get -b source dillo

Once it's downloaded and compiled the code, you'll be left with a .deb package in your /home directory, which you can install in the usual way. If you later need to remove it, you can use apt-get remove as normal.
There, that wasn't hard, was it? Ubuntu has several options available if you want to compile an application from source, and this is the easiest. I have to admit I don't use this much, but it can be worthwhile.

No comments: