Compiling (Just About) Anything in Ubuntu

May 9, 2008 – 5:02 pm by \m/ike

Some basic commands for turning that .tar.gz into a happy .deb!

1. First of all, you’re going to need the proper equipment for any compiling job. Open up a terminal and type / copy-n-paste:

sudo aptitude update && sudo aptitude install build-essential checkinstall

This will get you going with the basic software needed, including Debian’s checkinstall which will try to make everything a deb before installing it (useful for uninstalling via apt/aptitude but doesn’t always work in my experience).

2. Next we need to find a source tar.gz to install. For this example, I’m going to use LAME. After downloading and extracting the archive, you should have a folder like “lame-3.98b8″ lying around. Get into a terminal and cd into that folder.

cd ~
wget http://internap.dl.sourceforge.net/sourceforge/lame/lame-3.98b8.tar.gz
tar -vzxf lame-3.98b8.tar.gz
cd
lame-3.98b8

3. Next comes probably the least fun part: resolving build dependencies. If this is an application that is also in the repository and you have all of your software sources checked (Menu -> System -> Administration -> Software Sources), you can try to type/copy-n-paste:

sudo apt-get build-dep lame

If this doesn’t work for you or it’s an application not in the repos, you will have to hunt down the build dependencies manually. This usually involves searching around the website of the application you’re trying to install, finding out which packages it requires, searching around in Synaptic for Ubuntu’s name for it, and installing them one by one (they usually end in “-dev”). If you don’t successfully acquire all the needed dependencies, you’re going to get some errors in the next step.

4. Finally, time for some compiling action. First, we need to type:

./configure

After a whole bunch of text, the command should exit without any errors. Note: there are usually arguments that can be passed here (--something) that will change how the application will be compiled. Check the developer’s website or readme for info. Next is time for:

make

After some time and more text (and hopefully no errors), we can issue:

sudo checkinstall

Hit enter to accept the defaults at the prompts. Hopefully checkinstall will be able to successfully convert the app to a .deb before automatically installing it. This is great because we can remove it in the future through Synaptic or by typing:

sudo aptitude remove lame

just like if it was an application installed from the repos. If for some reason this fails (and it fails more often then I’d like), you will have to issue:

sudo make install

instead, which will likely put the app in your /usr/local/bin folder. Applications installed this way can be uninstalled if you keep your original source directory, cd to it, and type:

sudo make uninstall

or sometimes

sudo make deinstall

If neither command works out for you, you will have to remove the app by hand, which can be a pain.

Hopefully this gives you an idea of the basic process of compiling programs from source. Different programs compile different ways (and some in ENTIRELY different ways) so always read any readme or installation instructions before getting your favorite app compiling!

Post a Comment