Date Sat 28 November 2009

A lot of people are scared off from compiling QGIS on Ubuntu thinking the process is too complicated. Actually its pretty easy and you can do it in just a few steps. This weekend I am updating my desktop PC from Ubuntu Jaunty 9.4 to Ubuntu Karmic 9.10 by way of a clean OS install, so I thought I would document the steps needed to get a working QGIS build environment set up in the hopes that others might like to try. Building QGIS from source lets you be an early adopter, trying out the many new cool features that have made their way into subversion (our source code repository), but that are not yet in our mainstream releases.

Installing Dependencies the easy way

Firstly add the ubuntu-gis repository to you apt sources list:

sudo su -c "echo 'deb karmic main' >> /etc/apt/sources.list"
sudo su -c "echo 'deb-src karmic main' >> /etc/apt/sources.list"

Now update your package database:

sudo apt-get update

Now tell Ubuntu to install all build dependencies for QGIS:

sudo apt-get build-dep qgis

Now say 'Y' at the prompt and if you are in South Africa wait a few hours while the bits crawl across the wires and deplete your bank account. On my clean system it downloaded around 124mb of packages - pretty much everything you need to build QGIS including the compiler environment, the dependent libraries and their header files etc.

Building QGIS

Building QGIS is well documented in our INSTALL document that comes included but here is the quick version:

First install subversion and cmake console, cmake qt4 gui's and a few other goodies:

sudo apt-get install subversion cmake-curses-gui \
cmake-qt-gui gdal-bin libgdal1-1.6.0-grass python-gdal

Now we can go on to build QGIS. I am telling CMAKE to install my hand built copy into my home directory (under a subdirectory called apps) to that it does not conflict with with any other copies of QGIS that may be on the system - although you may run into some issues with having a system level install of QIGS and a local copy unless you have tightly managed your library search paths.

mkdir -p dev/cpp
cd dev/cpp
svn co
cd qgis
mkdir build
cd build

Set your library search path

Note This section was added in an update on 31 Nov 2009

If you want the grass plugin to load in QGIS, you also need to ensure your library path is updated. I do it system wide. First edit /etc/ as root and add this line:


Now do:

sudo ldconfig

Running QGIS

I add a launcher to my Gnome panel that points to /home/timlinx/apps/bin/qgis. After that your hand build QGIS will be a simple click away. QGIS source code is always under development and we try at all times to ensure the code in SVN will build cleanly. If you want to get the latest updates, simply do:

cd dev/cpp/qgis
svn update
cd build
make install

Assuming you got no error messages during the build, you QGIS launcher icon should now launch the latest build.


comments powered by Disqus