Home » Operating Systems » Basic guide to compiling packages from source on Ubuntu

Basic guide to compiling packages from source on Ubuntu

The word “compiling” intimidates a lot of novice or even intermediate users of Linux. In reality, compiling software packages on Ubuntu is not that difficult. In this post, we will explain what you need to know about compiling packages from source on Ubuntu. Some of the guides on htpcBeginner (installing CrystalHD, XBMC, etc.) talk about compiling packages from source on Ubuntu. We have more guides on the way that would require compiling packages as well. Therefore, we thought it is time to provide the new Linux users a very basic introduction to compiling packages from source on Ubuntu. So here it goes.

Compiling Packages from Source on Ubuntu

Why Do You Need to Compile Packages?

Compilation is the process of processing the source code (programming codes), customizing them to your environment (system/OS), and converting them to installable files. The packages available on Ubuntu repositories or the .deb files are pre-compiled packages that you can install with a quick command. But many times some of the software packages available on the repository are older versions. Furthermore, some of the packages are not even available in the repositories. So if you want the latest and the greatest, you can download the latest source code, compile, and install it. While the process is longer than installing from the repositories, compilation makes that software the most responsive it can be for your system/environment. Once you know how to do it, it is an extremely easy process as, in most cases, all you have to do is issue a sequence of few commands.

Prerequisites for Compiling Packages from Source on Ubuntu

A typical user does not compile packages, therefore Ubuntu decided not to include the prerequisites for compiling packages into the distribution. The following command installs all the packages necessary for compiling packages on from Source on Ubuntu:

sudo apt-get install autoconf g++ subversion linux-source linux-headers-`uname -r` build-essential tofrodos git-core subversion dos2unix make gcc automake cmake checkinstall git-core dpkg-dev fakeroot pbuilder dh-make debhelper devscripts patchutils quilt git-buildpackage pristine-tar git yasm checkinstall cvs mercurial

This covers most common packages required for compiling downloaded packages, including those from SVN and Git.

Downloading Packages

Many of the source codes are downloaded as compressed tar files. These can be extracted using the following commands:

For tar.gz files:

tar -xzvf tarballname.tar.gz

For tar.gz.bz2 files:

tar -xjvf tarballname.tar.bz2

If the source code is from SVN or Git, the developers will provide instructions on how to get them. Typically for Git, the git clone command is used. In our guides, we clearly specify the instructions on how to download from SVN or Git.

Recommended Reading:

Compiling Packages from Source on Ubuntu

Compilation processes involves only 3 steps: configure, make, and install. The first step is configure. Most downloaded sources (tar files) will already have a configure. To configure the compilation files issue the following command:


Some source codes downloaded from Git or SVN may not have the configure. These will normally include a autogen script which relies on automake and autoconf programs and will automatically build the configuration files and run the ./configure command.


The next step is to make the installation files by compiling the source code, using the following command:


Depending on the size of the source code this step can take minutes to hours. If you have a multi-core process this can be done quicker by utilizing multiple cores. For example, if you have a quad-core processor you can use the following command instead:

make -j4

Continued in next page

We Are Hiring: Familiar with Media Streaming, HTPC, Home Server, Smart Home, and Home Automation topics? Write about it and earn money. No writing experience needed. APPLY HERE.

Get 20% OFF with IPVanish VPN:

♦   Hide your browsing and streaming activity: No logs and no tracking
♦   Access geo-restricted content from anywhere
♦   Encrypt and anonymize: Kodi, Plex, Downloads, Personal Info
♦   Windows, Mac, Linux, Android, iOS, Router, and more.
♦   Money back guarantee - Sign Up Now

About the author


Anand is a self-learned computer enthusiast, a part-time blogger, and a Food Scientist by career. He has been blogging since 2010 on Linux, Ubuntu, Home/Media/File Servers, Smart Home Automation, and related HOW-TOs on htpcbeginner.com and smarthomebeginner.com.


Join the other 110,000 followers

Don’t Miss Out!