Tutorials

How to Build Open-Source Software

OSS Installation

As Open-Source Software is distributed mainly as source and not as a binary installer, the installation of such a software requires the following steps:

The Open Source Software (OSS) usually comes as a so called source tar ball that contains the entire source code and build infrastructure. A source tar ball has the suffix .tgz or .tar.gz.

Supposed, we have downloaded the tarball of an Open-Source Software named source.tgz, we unarchive and uncompress it on the Unix command line:

gtar zxvf source.tgz

Alternatively, if the source code is hosted on a SVN server you can download the software with the Subversion development tools. Supposed the URL of the software repository is given as http://svn.address, we download the latest version of the software via SVN:

svn co http://svn.address

Previous versions can be checked out with the -r option with r standing for revision. Revisions have increasing numbers, so 1 stands for the first version of the software in the SVN repository. We check out that version, like so:

svn co -r 1 http://svn.address

Now that we have downloaded or checked out the OSS to a local working directory, we need to build the software. For that purpose, we first need a so called compiler, for example the open source compiler collection (GCC). Please make sure that you have it installed.

As build infrastructure, two main build systems ave emerged as the defacto standard for Open-Source Projects:

  • Autoconf/Automake (Unix only)
  • CMake (multi-platform: Mac, Unix, Windows)

To see which build system the project supports we have a look at the contents of the source repository:

  • The existence of configure indicates Autoconf/Automake as the build system.
  • The existence of CMakeLists.txt indicates CMake as the build system.

If we have identified Autoconf/Automake as the build system, we build the software with the following shell command:

./configure && make

Otherwise, if we have identified CMake as the build system, we build the software with the following shell command:

cmake . && make

If there were no errors during compilation (bleeding edge versions from the head of SVN are not always guaranteed to work flawless on all platforms, release versions tagged as such in the SVN repository subfolder “tags” are guaranteed to be stable), we can install the software on our computer with the following command:

make install

The default installation directory is /usr/local. In case you need root priviledges for the installation to that directory, we run the installation command as super user (super user do = sudo):

sudo make install

If you do not have root priviledges, we can still install the software locally to our home folder. In the following we name the home folder /home/user/. We need to tell the build system that we have a different installation directory:

With Autoconf/Automake:

./configure --prefix=/home/user && make

With CMake:

cmake -DCMAKE_INSTALL_PREFIX=/home/user . && make

Note: With the local installation option, you may have to add the installation directory to your search path.

Now we have successfully downloaded, built and installed OSS software!

Options: