11Quantum GIS (QGIS)
22Building QGIS from source - step by step
3- Sunday August 07 , 2011
3+ Sunday November 06 , 2011
44
55
6- Last Updated: Sunday August 07 , 2011
7- Last Change : Tuesday June 28 , 2011
6+ Last Updated: Sunday November 06 , 2011
7+ Last Change : Sunday November 06 , 2011
88
99
1010 1. Introduction
@@ -81,9 +81,9 @@ Following a summary of the required dependencies for building:
8181
8282Required build tools:
8383
84- - CMake >= 2.6.0
84+ - CMake >= 2.6.2
8585- Flex
86- - Bison
86+ - Bison >= 2.4
8787
8888Required build deps:
8989
@@ -321,10 +321,10 @@ Install them using dpkg. E.g.:
321321 3.9. A practical case: Building QGIS and GRASS from source on Ubuntu with ECW and MrSID formats support
322322 =======================================================================================================
323323
324- The following procedure has been tested on Ubuntu 8.04, 8.10 and 9.04 32bit. If you want
325- to use different versions of the software (gdal, grass, qgis), just make the
326- necessary adjustments to the following code. This guide assumes that you don't have
327- installed any previous version of gdal, grass and qgis.
324+ The following procedure has been tested on Ubuntu 8.04, 8.10 and 9.04 32bit. If
325+ you want to use different versions of the software (gdal, grass, qgis), just
326+ make the necessary adjustments to the following code. This guide assumes that
327+ you don't have installed any previous version of gdal, grass and qgis.
328328
329329
330330 3.9.1. Step 1: install base packages
@@ -344,7 +344,7 @@ Go to the ERDAS web site http://www.erdas.com/ and follow the links
344344then download the "'Image Compression SDK Source Code 3.3'" (you'll need to make a registration
345345and accept a license).
346346
347- Uncompress the arquive in a proper location (this guide assumes
347+ Uncompress the archive in a proper location (this guide assumes
348348that all the downloaded source code will be placed in the user home)
349349and the enter the newly created folder
350350
@@ -439,23 +439,32 @@ leave the folder
439439Before downloading and compile GRASS source code you need to install a few
440440other libraries and programs. We can do this through apt
441441
442- sudo apt-get install flex bison libreadline5-dev libncurses5-dev lesstif2-dev debhelper dpatch libtiff4-dev \
443- tcl8.4-dev tk8.4-dev fftw-dev xlibmesa-gl-dev libfreetype6-dev autoconf2.13 autotools-dev \
444- libgdal1-dev proj libjpeg62-dev libpng12-dev libpq-dev unixodbc-dev doxygen fakeroot cmake \
445- python-dev python-qt4-common python-qt4-dev python-sip4 python2.5-dev sip4 libglew1.5-dev libxmu6 \
446- libqt4-dev libgsl0-dev python-qt4 swig python-wxversion python-wxgtk2.8 libwxgtk2.8-0 libwxbase2.8-0 tcl8.4-dev \
447- tk8.4-dev tk8.4 libfftw3-dev libfftw3-3
442+ sudo apt-get install flex bison libreadline5-dev libncurses5-dev lesstif2-dev \
443+ debhelper dpatch libtiff4-dev tcl8.4-dev tk8.4-dev fftw-dev xlibmesa-gl-dev \
444+ libfreetype6-dev autoconf2.13 autotools-dev libgdal1-dev proj libjpeg62-dev \
445+ libpng12-dev libpq-dev unixodbc-dev doxygen fakeroot cmake python-dev \
446+ python-qt4-common python-qt4-dev python-sip4 python2.5-dev sip4 libglew1.5-dev \
447+ libxmu6 \ libqt4-dev libgsl0-dev python-qt4 swig python-wxversion \
448+ python-wxgtk2.8 libwxgtk2.8-0 libwxbase2.8-0 tcl8.4-dev tk8.4-dev tk8.4 \
449+ libfftw3-dev libfftw3-3
448450
449451At this point we can get the GRASS source code: you may want to download it
450- through svn or maybe you want just to download the latest available source code arquive.
451- For example the GRASS 6.4rc4 is available at http://grass.itc.it/grass64/source/grass-6.4.0RC4.tar.gz
452+ through svn or maybe you want just to download the latest available source code
453+ archive. For example the GRASS 6.4rc4 is available at
454+ http://grass.itc.it/grass64/source/grass-6.4.0RC4.tar.gz
452455
453- Uncompress the arquive , enter the newly created folder and run configure with a few specific parameters
456+ Uncompress the archive , enter the newly created folder and run configure with a few specific parameters
454457
455- CFLAGS="-fexceptions" ./configure --with-tcltk-includes=/usr/include/tcl8.4 --with-proj-share=/usr/share/proj --with-gdal=/usr/local/bin/gdal-config \
458+ CFLAGS="-fexceptions" ./configure \
459+ --with-tcltk-includes=/usr/include/tcl8.4 \
460+ --with-proj-share=/usr/share/proj \
461+ --with-gdal=/usr/local/bin/gdal-config \
456462 --with-python=/usr/bin/python2.5-config
457463
458- The additional gcc option -fexceptions is necessary to enable exceptions support in GRASS libraries. It is currently the only way to avoid QGIS crashes if a fatal error happens in GRASS library. See also http://trac.osgeo.org/grass/ticket/869
464+ The additional gcc option -fexceptions is necessary to enable exceptions
465+ support in GRASS libraries. It is currently the only way to avoid QGIS crashes
466+ if a fatal error happens in GRASS library. See also
467+ http://trac.osgeo.org/grass/ticket/869
459468
460469Then as usual (it will take a while)
461470
@@ -475,31 +484,21 @@ may want to give it a try
475484 grass64 -wxpython
476485
477486
478- 3.9.6. Step 6: compile and install QGIS
487+ 3.9.6. Step 6: Compile and install QGIS
479488 =======================================
480489
481- As for GRASS you can obtain the QGIS source code from different sources,
482- for instance from svn or just by downloading one of the source code arquives available
483- at http://www.qgis.org/download/sources.html
490+ As for GRASS you can obtain the QGIS source code from different sources as described
491+ in section 2 above. Once you have the sources, create a build directory in them:
484492
485- For example download the QGIS 1.1.0 source code here http://download.osgeo.org/qgis/src/qgis_1.1.0.tar.gz
486-
487- uncompress the arquive and enter the newly created folder
488-
489- cd /qgis_1.1.0
493+ cd Quantum-GIS
494+ mkdir build
495+ cd build
490496
491497then run ccmake
492498
493- ccmake .
494-
495- press the "c" key, then when the option list will appear we need to manually
496- configure the "GRASS_PREFIX" parameter. Scroll down until the "GRASS_PREFIX" will appear,
497- press enter and manually set it to
498-
499- /usr/local/grass-6.4.0RC4
500-
501- then press enter again.
499+ ccmake ..
502500
501+ Press the "c" key to do an initial configure.
503502Press the "c" again and the option "Press [g] to generate and exit" will appear.
504503Press the "g" key to generate and exit.
505504
@@ -621,13 +620,9 @@ installed in the default locations):
621620 @cmd
622621
623622Start the batch file and on the command prompt checkout the QGIS source from
624- svn to the source directory qgis-trunk:
625-
626- svn co https://svn.osgeo.org/qgis/trunk/qgis qgis-trunk
623+ git to the source directory Quantum-GIS:
627624
628- or using git-svn (from the git shell):
629-
630- git svn clone --username $USER --revision 15611:HEAD https://svn.osgeo.org/qgis/trunk/qgis
625+ git clone git://github.com/qgis/Quantum-GIS.git
631626
632627Create a 'build' directory somewhere. This will be where all the build output
633628will be generated.
@@ -1154,9 +1149,9 @@ In this approach I will try to avoid as much as possible building dependencies
11541149from source and rather use frameworks wherever possible.
11551150
11561151The base system here is Mac OS X 10.4 (Tiger), with a single architecture
1157- build. Included are notes for building on Mac OS X 10.5 (Leopard) and 10.6
1158- (Snow Leopard). Make sure to read each section completely before typing
1159- the first command you see.
1152+ build. Included are notes for building on Mac OS X 10.5 (Leopard), 10.6
1153+ (Snow Leopard) and 10.7 (Lion).
1154+ Make sure to read each section completely before typing the first command you see.
11601155
11611156General note on Terminal usage: When I say "cd" to a folder in a Terminal,
11621157it means type "cd " (without the quotes, make sure to type a space after) and
@@ -1187,10 +1182,12 @@ You need a minimum of Qt-4.4.0. I suggest getting the latest. There is no need
11871182for the full Qt SDK, so save yourself some download time and get the frameworks
11881183only.
11891184
1190- Snow Leopard note: If you are building on Snow Leopard, you will need to
1191- decide between 32-bit support in the older, Qt Carbon branch, or 64-bit
1185+ Snow Leopard+ note: If you are building on Snow Leopard+ , you will need to
1186+ decide between 32-bit support in the older Qt Carbon branch, or 64-bit
11921187support in the Qt Cocoa branch. Appropriate installers are available for both
1193- as of Qt-4.5.2. Qt 4.6+ is recommended for Cocoa.
1188+ as of Qt-4.5.2, though they stopped making Carbon packages at Qt 4.7.4.
1189+ Qt 4.6+ is recommended for Cocoa.
1190+ Starting with Lion, Carbon may not work properly, if at all.
11941191
11951192PPC note: The readymade Qt Cocoa installers don't include PPC support, you'd
11961193have to compile Qt yourself. But, there appear to be issues with Qt Cocoa on
@@ -1258,8 +1255,8 @@ have problems and you are on your own with those.
12581255 5.2.2. Additional Dependencies: Expat
12591256 =====================================
12601257
1261- Snow Leopard note: Snow Leopard includes a usable expat, so this step is
1262- not necessary on Snow Leopard.
1258+ Snow Leopard+ note: Snow Leopard includes a usable expat, so this step is
1259+ not necessary on Snow Leopard or Lion .
12631260
12641261Get the expat sources:
12651262
@@ -1276,10 +1273,10 @@ source folder and:
12761273 5.2.3. Additional Dependencies: Python
12771274 ======================================
12781275
1279- Leopard and Snow Leopard note: Leopard and Snow Leopard include a usable
1280- Python 2.5 and 2.6 , respectively. So there is no need to install Python on
1281- Leopard and Snow Leopard. You can still install Python from python.org if
1282- preferred.
1276+ Leopard+ note: Starting with Leopard a usable Python is included
1277+ in the system. This Python 2.5, 2.6 and 2.7 , respectively for Leo, Snow and Lion.
1278+ So there is no need to install Python on Leopard and newer.
1279+ You can still install Python from python.org if preferred.
12831280
12841281If installing from python.org, make sure you install at least the latest Python
128512822.x from
@@ -1314,12 +1311,13 @@ More configuration is needed to install outside the system path:
13141311 python configure.py -n -d /Library/Python/2.5/site-packages -b /usr/local/bin \
13151312 -e /usr/local/include -v /usr/local/share/sip -s MacOSX10.5.sdk
13161313
1317- Snow Leopard system Python
1314+ Snow Leopard+ system Python
13181315
13191316Similar to Leopard, you should install outside the system Python path.
13201317Also, you need to specify the architecture you want (requires at least SIP
132113184.9), and make sure to run the versioned python binary (this one responds to
13221319the 'arch' command, 'python' does not).
1320+ Substitute '2.7' for python version and 10.7 for SDK version below for Lion.
13231321
13241322If you are using 32-bit Qt (Qt Carbon):
13251323
@@ -1361,12 +1359,13 @@ More configuration is needed to install outside the system path:
13611359
13621360 python configure.py -d /Library/Python/2.5/site-packages -b /usr/local/bin
13631361
1364- Snow Leopard system Python
1362+ Snow Leopard+ system Python
13651363
13661364Similar to Leopard, you should install outside the system Python path.
13671365Also, you need to specify the architecture you want (requires at least PyQt 4.6),
13681366and make sure to run the versioned python binary (this one responds to the
13691367'arch' command, which is important for pyuic4, 'python' does not).
1368+ Substitute '2.7' for python version and 10.7 for SDK version below for Lion.
13701369
13711370If you are using 32-bit Qt (Qt Carbon):
13721371
@@ -1435,7 +1434,7 @@ Carbon note below):
14351434
14361435Make sure to use the qwt install path from the Qwt build above.
14371436
1438- Snow Leopard note
1437+ Snow Leopard+ note
14391438
14401439If using Qt Carbon, you need to specify which architectures to build, otherwise
14411440it will default to a combination that does not work (ie x86_64 for a Carbon Qt).
@@ -1449,18 +1448,15 @@ This is not needed for Qt Cocoa. Configure as follows:
14491448 5.2.7. Additional Dependencies: Bison
14501449 =====================================
14511450
1452- Leopard and Snow Leopard note: Leopard and Snow Leopard include Bison 2.3,
1453- so this step can be skipped on Leopard and Snow Leopard.
1454-
1455- The version of bison available by default on Mac OS X 10.4 is too old so you
1456- need to get a more recent one on your system. Download at least version 2.3 from:
1451+ The version of bison available by default on Mac OS X is too old so you
1452+ need to get a more recent one on your system. Download at least version 2.4 from:
14571453
14581454 ftp.gnu.org/gnu/bison/
14591455
1460- Now build and install it to a prefix of /usr/local.� Double-click the source
1456+ Now build and install it to a prefix of /usr/local. Double-click the source
14611457tarball to unpack it, then cd to the source folder and:
14621458
1463- ./configure --prefix=/usr/local
1459+ ./configure --disable-dependency-tracking CFLAGS=-Os
14641460 make
14651461 sudo make install
14661462
@@ -1474,8 +1470,9 @@ http://www.cmake.org/cmake/resources/software.html
14741470
14751471Binary installers are available for OS X, but they are not recommended
14761472(2.4 versions install in /usr instead of /usr/local, and 2.6+ versions are a
1477- strange application). Instead, download the source, double-click the source
1478- tarball, then cd to the source folder and:
1473+ strange application). Instead, download the source.
1474+ NOTE: 2.8.5 is broken for detecting part of Qt. Fixed in 2.8.6.
1475+ Double-click the source tarball, then cd to the source folder and:
14791476
14801477 ./bootstrap --docdir=/share/doc/CMake --mandir=/share/man
14811478 make
@@ -1508,16 +1505,17 @@ CMake supports out of source build so we will create a 'build' dir for the
15081505build process. OS X uses ${HOME}/Applications as a standard user app folder (it
15091506gives it the system app folder icon). If you have the correct permissions you
15101507may want to build straight into your /Applications folder. The instructions
1511- below assume you are building into a pre-existing ${HOME}/Applications directory.
1508+ below assume you are building into a ${HOME}/Applications directory.
15121509In a Terminal cd to the qgis source folder previously downloaded, then:
15131510
15141511 mkdir build
15151512 cd build
15161513 cmake -D CMAKE_INSTALL_PREFIX=~/Applications \
15171514 -D CMAKE_BUILD_TYPE=MinSizeRel \
1518- -D WITH_INTERNAL_SPATIALITE=FALSE -D WITH_MAPSERVER=TRUE \
1515+ -D WITH_INTERNAL_SPATIALITE=FALSE \
15191516 -D QWT_LIBRARY=/usr/local/qwt-5.2.1-svn/lib/libqwt.dylib \
15201517 -D QWT_INCLUDE_DIR=/usr/local/qwt-5.2.1-svn/include \
1518+ -D BISON_EXECUTABLE=/usr/local/bin/bison \
15211519 ..
15221520
15231521This will automatically find and use the previously installed frameworks, and
@@ -1529,10 +1527,11 @@ path and version as required):
15291527
15301528 cmake -D CMAKE_INSTALL_PREFIX=~/Applications -D CMAKE_BUILD_TYPE=Release \
15311529 -D CMAKE_BUILD_TYPE=MinSizeRel \
1532- -D WITH_INTERNAL_SPATIALITE=FALSE -D WITH_MAPSERVER=TRUE \
1530+ -D WITH_INTERNAL_SPATIALITE=FALSE \
15331531 -D QWT_LIBRARY=/usr/local/qwt-5.2.1-svn/lib/libqwt.dylib \
15341532 -D QWT_INCLUDE_DIR=/usr/local/qwt-5.2.1-svn/include \
15351533 -D GRASS_PREFIX=/user/local/grass-6.4.1 \
1534+ -D BISON_EXECUTABLE=/usr/local/bin/bison \
15361535 ..
15371536
15381537Snow Leopard note: To handle 32-bit Qt (Carbon), create a 32bit python wrapper
@@ -1547,12 +1546,23 @@ script and add arch flags to the configuration:
15471546
15481547 cmake -D CMAKE_INSTALL_PREFIX=~/Applications -D \
15491548 -D CMAKE_BUILD_TYPE=MinSizeRel \
1550- -D WITH_INTERNAL_SPATIALITE=FALSE -D WITH_MAPSERVER=TRUE \
1549+ -D WITH_INTERNAL_SPATIALITE=FALSE \
15511550 -D QWT_LIBRARY=/usr/local/qwt-5.2.1-svn/lib/libqwt.dylib \
15521551 -D QWT_INCLUDE_DIR=/usr/local/qwt-5.2.1-svn/include \
1552+ -D BISON_EXECUTABLE=/usr/local/bin/bison \
15531553 -D CMAKE_OSX_ARCHITECTURES=i386 -D PYTHON_EXECUTABLE=/usr/local/bin/python32 \
15541554 ..
15551555
1556+ The Qgis Mapserver feature requires fastcgi support. This is included in
1557+ Leopard and Snow Leopard, but was dropped at Lion. To build the Mapserver
1558+ component on Leopard and Snow, add the followling line before the last line in
1559+ the above configuration:
1560+
1561+ -D WITH_MAPSERVER=TRUE \
1562+
1563+ On Lion you are on your own to figure out how to install libfcgi and add fcgi
1564+ support to the system Apache. Not recommended for the average user.
1565+
15561566Bundling note: Older Qt versions may have problems with some Qt plugins and
15571567Qgis. The way to handle this is to bundle Qt inside the Qgis application. You
15581568can do this now or wait to see if there are immediate crashes when running Qgis.
0 commit comments