Posted by & filed under QGIS.

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.

  • Barry Rowlingson

    Isn’t there a very important ‘../’ missing from your ccmake line – shouldn’t it be:

    ccmake -DCMAKE_INSTALL_PREFIX=${HOME}/apps \

    – then hit ‘c’ to configure and ‘g’ to generate, then quit and do the ‘make’ step.

    • admin


      I never use a ../. Assuming you are in your build dir which is nested in your QGIS checkout directory only .. is required.



  • rduivenvoorde

    one tip I got during the Vienna hackfest (though only usefull if you use ccmake for configuring and you build using plane make:

    – if you have a multicore cpu (even working for the dual-core atom in my little eeepc…):
    make -j2
    instead of the normal
    will speed up the compiling a lot (both cores will heat up :-) )

  • Pingback: Compiling QGIS Under Ubuntu 9.10 | Ubuntu-News - Your one stop for news about Ubuntu

  • aperson

    The preferred method of adding the ppa to your sources would be:

    This will add the relevant file in /etc/apt/sources.list.d and add the key in one go.

    sudo add-app-repository ppa:ubuntugis-unstable

    • admin


      Great tips thanks!



  • ttamba

    Hi Tim

    I’m QGIS user and found your post regarding building QGIS from source very interesting. I tried to go ahead and test it out from the trunk version on ubuntu 9.10, unfortunatelly I get the following error when building CMake and CCMake and it looks like the ‘
    ‘CMakelist.txt’ is missing…
    CMake Error: The source directory “/home/ttamba/dev/cpp/qgis/build” does not appear to contain CMakeLists.txt.
    Specify –help for usage, or press the help button on the CMake GUI.

    Errors occurred during the last pass
    CMake Version 2.6 – patch 4
    Press [e] to exit help


    Any idea of what is going wrong ???


    • admin


      It sounds like you are missing the ‘..’ (without quotes) at the end of your cmake line.



  • admin

    For Barry: apologies I see you were pointing out that the ‘..’ was completely ommitted – I thought you were suggesting to use ‘../’ rather than ‘..’ (which I guess would both do the same thing). I will correct the original article above.

    For everyone else who tried the procedure without success, please try again with the ‘..’ added.



  • ttamba

    Hi Tim,

    I received your answer since last sunday, but don’t have enough time to retest. I have done the test tonight but still getting error during make install

    Up-to-date: /usr/lib/python2.6/dist-packages/qgis/
    CMake Error at python/cmake_install.cmake:36 (FILE):
    file Problem setting permissions on file
    Call Stack (most recent call first):
    cmake_install.cmake:65 (INCLUDE)


  • admin


    It looks like you are installing to /usr instead of -DCMAKE_INSTALL_PREFIX=${HOME}/apps as per my notes above – in which case you should probably run make install as root e.g.:

    sudo make install



  • ttamba


    I’m sure that I’m installing qgis to Home directory because I created a Dev dirwich contains cpp, qgis and build subdirectories and the build process has been made inside the build subdirectory.
    I’ve tried to run with make install as root I don’t get any error message, but when I try to run qgis in the prompt, I get a notice that qgis cannot be be found….


  • rduivenvoorde


    I tried your tip (on a really fresh 9.10), but found that it should not be
    add-apt-repository (mind the T)

    besides that I got a http not found message if I try
    sudo add-apt-repository ppa:ubuntugis-unstable
    sudo add-apt-repository ppa:ubuntugis/ubuntugis-unstable/
    (though it says that it installs the “Launchpad ubuntugis-stable” key ??)
    And after that apparently we do not have the src-packages, I still had to do:
    sudo su -c “echo ‘deb-src karmic main’ >> /etc/apt/sources.list”
    to complete the rest of this workout of tim

  • Pingback: From Fedora 12 to a GIS workstation (part 3) « Scratching Surfaces

  • micka


    I’m having this error after launching the compilation :

    [ 7%] Generating
    Traceback (most recent call last):
    File “/usr/bin/pyuic4″, line 3, in ?
    import PyQt4.uic.pyuic
    ImportError: No module named PyQt4.uic.pyuic
    make[2]: *** [python/plugins/plugin_installer/] Error 1
    make[1]: *** [python/plugins/plugin_installer/CMakeFiles/pluginstaller.dir/all] Error 2
    make[1]: *** Waiting for unfinished jobs….

    [ 7%] Built target compile_python_files

    can you help me ?

  • micka

    i’ve already trying that :
    sudo apt-get install python-qt4

    but it is already installed :'(

  • cort

    The GRASS pluggin is not showing up in the pluggin manager. I have followed the steps exactly. any suggestions

    • Anne Ghisla

      is GRASS in this exact path?


      if not, adapt it to the actual path to GRASS lib folder.


  • samtux

    Hello, thank you very much for your blog. The following packages are also needed for the compilation of GRASS GIS:


    Thank you.

  • James

    Hi Tim,
    I recently ran into an error starting my QGIS application. This i assume is after I updated my SIP libraries. At startup of QGIS the following error is displayed:

    File “/usr/bin/pyuic4″, line 3, in
    import PyQt4.uic.pyuic
    File “/usr/lib/pymodules/python2.6/PyQt4/uic/”, line 4, in
    from PyQt4 import QtCore
    RuntimeError: the sip module implements API v7.0 to v7.1 but the PyQt4.QtCore module requires API v6.0

    This error also prevents me from re-installing QGIS following your steps above.
    I’ve tried removing SIP completely and repeating your steps to install the dependencies, but the error persists.

    Any suggestions on what I should do?