Unsupported Version
This article applies to an unsupported version of Ubuntu. More info...


Candidate for Deletion
This article may not be appropriate for this wiki, and may be deleted. More info...

Building QGIS 0.8 with Qt4.x


Requires: Ubuntu Edgy

See Also: BuildingQuantumGisFromSource

Document Maintainer: This document is maintained by Tim Sutton (tim _at_ linfiniti.com)

These notes are for if you want to build QGIS from source. One of the major aims here is to show how this can be done using binary packages for all dependencies - building only the core QGIS stuff from source. Currently the gdal grass raster driver needs to be built from source too - Ill revise these notes when a suitable package is available. I prefer this approach because it means we can leave the business of managing system packages to apt and only concern ourselves with coding QGIS! Note this document is still under construction...and is continually evolving.

As I write this QGIS 0.8 is undergoing major changes and is still considered unstable. QGIS 0.8 is a major revision of the QGIS codebase, including a port to Qt4. I will describe how to install it alongside your existing QGIS 0.7.4 install (which you can install using the procedure described in BuildingQuantumGisPoint7FromSource). This document assumes you have made a fresh install and have a 'clean' system. These instructions should work fine if this is a system that has already been in use for a while, you may need to just skip those steps which are irrelevant to you.

Warning /!\ Note: This is a 'cut and paste' tutorial - in most cases you can simply copy the commands listed in codeblocks that look like this:

somecommand to be pasted

Warning /!\ Note: This document is still under construction.

Prepare apt

The packages qgis depends on to build are available in the "universe" component of Ubuntu. This is not activated by default, so you need to activate it:

  1. Edit your /etc/apt/sources.list file.
  2. Uncomment the all the lines starting with "deb"

Also you will need to be running (K)Ubuntu 'edgy' in order for all dependencies to be met.

Now update your local sources database:

sudo apt-get update

Install Qt4

sudo apt-get install libqt4-core libqt4-debug libqt4-debug-dev libqt4-dev libqt4-gui libqt4-qt3support libqt4-sql lsb-qt4 qt4-designer qt4-dev-tools qt4-doc qt4-qtconfig uim-qt gcc libapt-pkg-perl resolvconf

Warning /!\ A Special Note: If you are following this set of instructions on a system where you already have Qt3 development tools installed, there will be a conflict between Qt3 tools and Qt4 tools. For example, qmake will point to the Qt3 version not the Qt4. Ubuntu Qt4 and Qt3 packages are designed to live alongside each other. This means that for example if you have them both installed you will have three qmake exe's:

/usr/bin/qmake -> /etc/alternatives/qmake

The same applies to all other Qt binaries. You will notice above that the canonical 'qmake' is managed by apt alternatives, so before we start to build QGIS, we need to make Qt4 the default. To return Qt3 to default later you can use this same process.

You can use apt alternatives to correct this so that the Qt4 version of applications is used in all cases:

sudo update-alternatives --config qmake
sudo update-alternatives --config uic
sudo update-alternatives --config designer
sudo update-alternatives --config assistant
sudo update-alternatives --config qtconfig
sudo update-alternatives --config moc
sudo update-alternatives --config lupdate
sudo update-alternatives --config lrelease
sudo update-alternatives --config linguist

Use the simple command line dialog that appears after running each of the above commands to select the Qt4 version of the relevant applications.

Install additional software dependencies required by QGIS

sudo apt-get install gdal-bin libgdal1-dev libgeos-dev proj libtool libgdal-doc libhdf4g-dev libhdf4g-run autoconf2.13 automake1.9 python-dev swig libgsl0-dev g++ libjasper-1.701-dev libtiff4-dev  subversion gsl-bin libsqlite3-dev sqlite3 ccache make libpq-dev flex bison firefox

GRASS Specific Steps

Warning /!\ Note: If you don't need to build with GRASS support, you can skip this section.

Now you can install grass from dapper:

sudo apt-get install grass libgrass-dev libgdal1-grass

Setup ccache (Optional)

You should also setup ccache to speed up compile times:

cd /usr/local/bin
sudo ln -s /usr/bin/ccache gcc
sudo ln -s /usr/bin/ccache g++

Prepare your development environment

As a convention I do all my development work in $HOME/dev/<language>, so in this case we will create a work environment for C++ development work like this:

mkdir -p ${HOME}/dev/cpp
cd ${HOME}/dev/cpp

This directory path will be assumed for all instructions that follow.

Check out the QGIS Source Code

There are two ways the source can be checked out. Use the anonymous method if you do not have edit privaleges for the QGIS source repository, or use the developer checkout if you have permissions to commit source code changes.

1. Anonymous Checkout

cd ${HOME}/dev/cpp
svn co https://svn.qgis.org/repos/qgis/trunk/qgis qgis

2. Developer Checkout

cd ${HOME}/dev/cpp
svn co --username <yourusername> https://svn.qgis.org/repos/qgis/trunk/qgis qgis

The first time you check out the source you will be prompted to accept the qgis.org certificate. Press 'p' to accept it permanently:

Error validating server certificate for 'https://svn.qgis.org:443':
 - The certificate is not issued by a trusted authority. Use the
   fingerprint to validate the certificate manually!
Certificate information:
 - Hostname: svn.qgis.org
 - Valid: from Apr  1 00:30:47 2006 GMT until Mar 21 00:30:47 2008 GMT
 - Issuer: Developer Team, Quantum GIS, Anchorage, Alaska, US
 - Fingerprint: 2f:cd:f1:5a:c7:64:da:2b:d1:34:a5:20:c6:15:67:28:33:ea:7a:9b
(R)eject, accept (t)emporarily or accept (p)ermanently?

Starting the compile

I compile my development version of QGIS into my ~/apps directory to avoid conflicts with Ubuntu packages that may be under /usr. This way for example you can use the binary packages of QGIS on your system along side with your development version. I suggest you do something similar:

mkdir -p ${HOME}/apps

I have written a script to automate building on debian. Simply go into the qgis checkout dir and run the script to commence building:

cd ${HOME}/dev/cpp/qgis
./build.sh ${HOME}/apps debug

The second option above is the destination / install dir, and the xdebug tells the script to build QGIS with debug symbols and verbose debug output. At the end of the autogen / configure process called by the script above you should see output like below, indicating that QGIS is going to be built with all its bells & whistles...

qgis 0.8.0
GDAL/OGR      : yes (Version 1.2.6)
GEOS          : yes (Version 2.1.4)
PostgreSQL    : yes (Version 8.1.4)
GRASS         : yes
SPIT          : yes
Georeferencer : yes
GPS/GPX       : yes
PROJ4         : yes
SQLITE3       : yes
Python        : yes

CXXFLAGS      : -g -O2

Debug         : no
Plugin dir    : /home/timlinux/apps/lib/qgis

The binary will be installed in /home/timlinux/apps/bin

The build is using Qt in /usr
Linking with Qt using -lQtCore -lQt3Support -lQtGui -lQtNetwork -lQtSvg -lQtCore -lQt3Support -lQtGui -lQtNetwork -lQtXml -lQtSvg -lQtTest -lQtDesigner
Configure finished, type 'make' to build.

The script will carry on to build QGIS - it may take a little while to go and have a cup of your favourite beverage while you wait...

Running QGIS

Once the compile is complete it should pop up a page in firefox with unit test results. At the time of writing the unit tests are just stubs - we still need to create the test implementations - so dont worry to much about their output at the moment.

Now you can try to run QGIS:


If all has worked properly the QGIS application should start up and appear on your screen.

Please visit http://qgis.org for information on joining our mailing lists and getting involved in the project further.

BuildingQuantumGisPoint8FromSource (last edited 2017-09-04 21:35:12 by rocket2dmn)