Source Code Compilation. Tutorial for Beginners Print

 

The reprint of this tutorial is authorized only with the active link: http://www.assistcg.com/

Most of the applications are available through distributive's package manager (you may use command line apt-get or Synaptic with GUI). But sometimes you need to install newest version of application that can't be downloaded with working binary executables as is. In this case compiling from source code may help.

To start installing application from source code you need to download archive with sources. Usually it is tar.bz or tar.gz archive. You can unpack them by the following commands:
#tar xjf package.tar.bz
or
#tar xzf package.tar.gz
Of course you may use GUI utilities like file-roller too.

You need to ensure that all required programs and libraries for compilation present in the system. It could be done by installing package "build-essential" using Synaptic or apt-get.
To run Synaptic you may click menu System -> Administration -> Synaptic. Then click on the "Search" button in Synaptic and enter "build-essential". Select the "build-essential" package for installation and click "Apply". After installation you may start compiling application. This procedure needs to be done only once.

In common case you may compile application by three simple commands that we run from command line in the root of the application's source tree:
#cd [path to the unpacked application sources]
#./configure
#make
#make install


The last command should be done with root privileges, this could be done by using su or sudo command.

Often we have unsatisfied dependencies during configuration and compilation. Sometimes it is easy to resolve these dependencies but sometimes not. The first step to resolve these issues is to determine which library is required for compilation. We can read this information from the output of "configure" script. For example, during the configuration you may recieve the following message: "libpng-1.2.8 or higher required". In this case we run Synaptic and search for libpng. We will receive the following results:
- libpng12-0 (marked in green, installed already usually)
- libpng12-dev (not marked)

Select libpng12-dev (this package contains files required for building application with libpng dependency) and install it. This manipulation resolves libpng dependency issue and you may continue configuring application for further build.
In some cases there are no packages in the distributive for the required library, you'll need to search and download source code for those libraries and perform their compilation.

Generally, if you follow this simple recommendation you'll be able to compile applications from source code, but in some cases problems still may arise. That is why we've created corresponding branch on the forum where you may ask questions about problems with building applications from source code.