June 14, 2008

What You Need to Compile Software in Debian

Make sure to have sources packages enabled
First of all, make sure that you have included sources repositories in your /etc/apt/sources.list file. That is, a line which starts with deb-src should be there, like this one:

deb-src ftp://ftp.ro.debian.org/debian/ lenny main contrib non-free

You can read this how-to to see how to use a text editor and edit this file if you're new to Linux.

Install the tools needed for compiling
Next, install the package build-essential, which will automatically install the main tools needed to perform a compilation, like gcc, g++ or make:

apt-get install build-essential

Note: You have to be root in order to install software with apt-get. Type su in a shell and enter your password. For security reasons (sometimes you will need to copy/paste a portion to an IRC channel or Pastebin in order to troubleshoot something), the password is hidden when you type it, but it goes in. Press Enter when you're done.

Note: Ubuntu users, precede these commands with sudo, since the root account is disabled by default in Ubuntu.

Fetch the dependencies
Usually, you will want to install newer versions of the applications already present in the repositories. For example, the current version of Wine in the Debian Lenny repositories is 1.0RC2 (release candidate 2), but the latest Wine version is 1.0RC5. So what you'll actually need are the dependencies of Wine, and to install them do:

apt-get build-dep wine

The same goes for any other application, like Amarok or XChat, for example. The only problem which can appear is when newer releases need several more dependencies or newer versions than the ones already present in the repositories (which get installed with apt-get build-dep) in order to compile.

Compile the source code
Next, just uncompress your source, change the current working directory to whatever yours is called and follow the usual steps, i.e.:

make install

The application should now be installed.

Get help reading the INSTALL and README files
Some applications have specific steps which you must follow, so make sure to read either the README or INSTALL files coming with the source code.

For applications which are not in the repositories, read the instructions provided by the INSTALL or README files included with the source. Every decent application provides enough instructions for you to be able to fetch the necessary development libraries.

Uninstall applications that you compiled
I recommend you keep the source directories of the applications you install this way, so that way if you'll need to uninstall it in the future and use the repositories or any other version, you'll only have to issue this command in the source's directory (as root):

make uninstall

Updated: Jun 18, 2008 (Created: Jun 14, 2008)

No comments: