Debian Linux logo


There are times when you need to compile software from sources, maybe because you need to compile the package with some specific option that is not enabled in the default package.

Do that in Debian is really easy.

Compile software from sources in Debian

Fetch the dependencies

The first thing you need, is to be sure that your Linux has all dependencies installed, so run:

apt-get update


apt-get build-dep htop

I’m using htop as the example in this article.

Now we have all dependencies solved.

Get the sources of the package

Continuing with our example, run:

cd /tmp

You may want to change to tmp folder, as in that folder the sources will be downloaded. Then get the sources

apt-get source htop

Then enter into the folder of the sources, in our case.

cd htop-0.7

Then you are ready to change the default options, if you need to do it.

Compile the software

dpkg-buildpackage -uc -b

Install the package into your Debian or Ubuntu Linux

dpkg -i ../htop_0.7-1_i386.deb


Please be sure to have a source repository in your /etc/apt/sources.list file

This is the minimum needed:

deb stable main
deb-src stable main

deb stable/updates main contrib

Other option

You can also use this other option to compile the software.

apt-get --build source htop

Update, 12/17/10: I did not realized that my friend Raphael Hertzog has already covered this just one day before I did. You may want to check his version for more tips and options