1
1
QGIS
2
2
Building QGIS from source - step by step
3
- Thursday November 13 , 2014
3
+ Saturday November 22 , 2014
4
4
5
5
6
- Last Updated: Thursday November 13 , 2014
7
- Last Change : Thursday November 13 , 2014
6
+ Last Updated: Saturday November 22 , 2014
7
+ Last Change : Saturday November 22 , 2014
8
8
9
9
10
10
1. Introduction
@@ -18,7 +18,6 @@ Last Change : Thursday November 13, 2014
18
18
3.6. Check out the QGIS Source Code
19
19
3.7. Starting the compile
20
20
3.8. Building Debian packages
21
- 3.9. A practical case: Building QGIS and GRASS from source on Ubuntu with ECW and MrSID formats support
22
21
4. Building on Windows
23
22
4.1. Building with Microsoft Visual Studio
24
23
4.2. Building using MinGW
@@ -96,7 +95,7 @@ Required build tools:
96
95
- Flex
97
96
- Bison >= 2.4
98
97
99
- Required build deps :
98
+ Required build dependencies :
100
99
101
100
- Qt >= 4.7.0
102
101
- Proj >= 4.4.x
@@ -116,6 +115,15 @@ Optional dependencies:
116
115
- for mapserver export and PyQGIS - Python >= 2.3 (2.5+ preferred)
117
116
- for python support - SIP >= 4.12, PyQt >= 4.8.3 must match Qt version, Qscintilla2
118
117
- for qgis mapserver - FastCGI
118
+ - for oracle provider - Oracle OCI library
119
+
120
+ Indirect dependencies:
121
+
122
+ Some proprietary formats (eg. ECW and MrSid) supported by GDAL require
123
+ proprietary third party libraries. QGIS doesn't need any of those itself to
124
+ build, but will only support those formats if GDAL is built accordingly. Refer
125
+ to http://gdal.org/formats_list.html ff. for instructions how to include
126
+ those formats in GDAL.
119
127
120
128
121
129
3. Building on GNU/Linux
@@ -127,41 +135,40 @@ Optional dependencies:
127
135
128
136
Requires: Ubuntu / Debian derived distro
129
137
138
+ /!\ Note: Refer to the section Building Debian packages for building
139
+ debian packages. Unless you plan to develop on QGIS, that is probably the
140
+ easiest option to compile and install QGIS.
141
+
130
142
These notes are for Ubuntu - other versions and Debian derived distros may
131
143
require slight variations in package names.
132
144
133
145
These notes are for if you want to build QGIS from source. One of the major
134
146
aims here is to show how this can be done using binary packages for *all*
135
147
dependencies - building only the core QGIS stuff from source. I prefer this
136
148
approach because it means we can leave the business of managing system packages
137
- to apt and only concern ourselves with coding QGIS!
149
+ to apt and only concern ourselves with coding QGIS!
138
150
139
151
This document assumes you have made a fresh install and have a 'clean' system.
140
152
These instructions should work fine if this is a system that has already been
141
153
in use for a while, you may need to just skip those steps which are irrelevant
142
154
to you.
143
155
144
- /!\ Note: Refer to the section Building Debian packages for building
145
- debian packages. Unless you plan to develop on QGIS, that is probably the
146
- easiest option to compile and install QGIS.
147
-
148
156
149
157
3.2. Prepare apt
150
158
================
151
159
152
- The packages qgis depends on to build are available in the "universe" component
160
+ The packages QGIS depends on to build are available in the "universe" component
153
161
of Ubuntu. This is not activated by default, so you need to activate it:
154
162
155
- 1. Edit your /etc/apt/sources.list file.
163
+ 1. Edit your /etc/apt/sources.list file.
156
164
2. Uncomment all the lines starting with "deb"
157
165
158
- Also you will need to be running (K) Ubuntu 'edgy ' or higher in order for
166
+ Also you will need to be running Ubuntu 'precise ' or higher in order for
159
167
all dependencies to be met.
160
168
161
169
Now update your local sources database:
162
170
163
- sudo apt-get update
164
-
171
+ sudo apt-get update
165
172
166
173
167
174
3.3. Install build dependencies
@@ -178,52 +185,15 @@ Now update your local sources database:
178
185
179
186
(extracted from the respective control files in debian/)
180
187
181
- /!\ A Special Note: If you are following this set of instructions on
182
- a system where you already have Qt3 development tools installed, there will
183
- be a conflict between Qt3 tools and Qt4 tools. For example, qmake will
184
- point to the Qt3 version, not the Qt4. Ubuntu Qt4 and Qt3 packages are
185
- designed to live alongside each other. This means that, for example, if you
186
- have them both installed, you will have three qmake exe's:
187
-
188
- /usr/bin/qmake -> /etc/alternatives/qmake
189
- /usr/bin/qmake-qt3
190
- /usr/bin/qmake-qt4
191
-
192
- The same applies to all other Qt binaries. You will notice above that the
193
- canonical 'qmake' is managed by apt alternatives, so before we start to
194
- build QGIS, we need to make Qt4 the default. To return Qt3 to default later
195
- you can use this same process.
196
-
197
- You can use apt alternatives to correct this so that the Qt4 version of
198
- applications is used in all cases:
199
-
200
- sudo update-alternatives --config qmake
201
- sudo update-alternatives --config uic
202
- sudo update-alternatives --config designer
203
- sudo update-alternatives --config assistant
204
- sudo update-alternatives --config qtconfig
205
- sudo update-alternatives --config moc
206
- sudo update-alternatives --config lupdate
207
- sudo update-alternatives --config lrelease
208
- sudo update-alternatives --config linguist
209
-
210
- Use the simple command line dialog that appears after running each of the
211
- above commands to select the Qt4 version of the relevant applications.
212
-
213
- /!\ Note: For python language bindings. If your distributions ships with older
214
- versions of SIP or PyQt4 than specified in Section 2: Overview, you will need
215
- to build and install those packages from source if you want to include support
216
- for python language bindings.
217
-
218
188
219
189
3.4. Setup ccache (Optional)
220
190
============================
221
191
222
192
You should also setup ccache to speed up compile times:
223
193
224
- cd /usr/local/bin
225
- sudo ln -s /usr/bin/ccache gcc
226
- sudo ln -s /usr/bin/ccache g++
194
+ cd /usr/local/bin
195
+ sudo ln -s /usr/bin/ccache gcc
196
+ sudo ln -s /usr/bin/ccache g++
227
197
228
198
229
199
3.5. Prepare your development environment
@@ -233,8 +203,8 @@ As a convention I do all my development work in $HOME/dev/<language>, so in
233
203
this case we will create a work environment for C++ development work like
234
204
this:
235
205
236
- mkdir -p ${HOME}/dev/cpp
237
- cd ${HOME}/dev/cpp
206
+ mkdir -p ${HOME}/dev/cpp
207
+ cd ${HOME}/dev/cpp
238
208
239
209
This directory path will be assumed for all instructions that follow.
240
210
@@ -249,12 +219,12 @@ if you do not have edit privileges for the QGIS source repository, or use
249
219
250
220
1. Anonymous Checkout
251
221
252
- cd ${HOME}/dev/cpp
222
+ cd ${HOME}/dev/cpp
253
223
git clone git://github.com/qgis/QGIS.git
254
224
255
225
2. Developer Checkout
256
226
257
- cd ${HOME}/dev/cpp
227
+ cd ${HOME}/dev/cpp
258
228
git clone git@github.com:qgis/QGIS.git
259
229
260
230
@@ -266,7 +236,7 @@ conflicts with Ubuntu packages that may be under /usr. This way for example
266
236
you can use the binary packages of QGIS on your system along side with your
267
237
development version. I suggest you do something similar:
268
238
269
- mkdir -p ${HOME}/apps
239
+ mkdir -p ${HOME}/apps
270
240
271
241
Now we create a build directory and run ccmake:
272
242
@@ -275,15 +245,15 @@ Now we create a build directory and run ccmake:
275
245
cd build-master
276
246
ccmake ..
277
247
278
- When you run ccmake (note the .. is required!), a menu will appear where
248
+ When you run ccmake (note the .. is required!), a menu will appear where
279
249
you can configure various aspects of the build. If you do not have root
280
250
access or do not want to overwrite existing QGIS installs (by your
281
251
packagemanager for example), set the CMAKE_INSTALL_PREFIX to somewhere you
282
252
have write access to (I usually use ${HOME}/apps). Now press
283
253
'c' to configure, 'e' to dismiss any error messages that may appear.
284
- and 'g' to generate the make files. Note that sometimes 'c' needs to
254
+ and 'g' to generate the make files. Note that sometimes 'c' needs to
285
255
be pressed several times before the 'g' option becomes available.
286
- After the 'g' generation is complete, press 'q' to exit the ccmake
256
+ After the 'g' generation is complete, press 'q' to exit the ccmake
287
257
interactive dialog.
288
258
289
259
Now on with the build:
@@ -305,7 +275,7 @@ on your screen.
305
275
=============================
306
276
307
277
Instead of creating a personal installation as in the previous step you can
308
- also create debian package. This is done from the qgis root directory, where
278
+ also create debian package. This is done from the QGIS root directory, where
309
279
you'll find a debian directory.
310
280
311
281
First you need to install the debian packaging tools once:
@@ -314,7 +284,7 @@ First you need to install the debian packaging tools once:
314
284
315
285
First you need to create an changelog entry for your distribution. For example for Ubuntu Lucid:
316
286
317
- dch -l ~lucid --force-distribution --distribution lucid "lucid build"
287
+ dch -l ~precise --force-distribution --distribution precise "precise build"
318
288
319
289
The QGIS packages will be created with:
320
290
@@ -340,206 +310,6 @@ Install them using dpkg. E.g.:
340
310
sudo debi
341
311
342
312
343
- 3.9. A practical case: Building QGIS and GRASS from source on Ubuntu with ECW and MrSID formats support
344
- =======================================================================================================
345
-
346
- The following procedure has been tested on Ubuntu 8.04, 8.10 and 9.04 32bit. If
347
- you want to use different versions of the software (gdal, grass, qgis), just
348
- make the necessary adjustments to the following code. This guide assumes that
349
- you don't have installed any previous version of gdal, grass and qgis.
350
-
351
-
352
- 3.9.1. Step 1: install base packages
353
- ====================================
354
-
355
- First you need to install the necessary packages required to download the source
356
- code and compile it. Open the terminal and issue the following command:
357
-
358
- sudo apt-get install build-essential g++ subversion
359
-
360
-
361
- 3.9.2. Step 2: compile and install the ecw libraries
362
- ====================================================
363
-
364
- Go to the ERDAS web site http://www.erdas.com/ and follow the links
365
- "'products --> ECW JPEG2000 Codec SDK --> downloads'"
366
- then download the "'Image Compression SDK Source Code 3.3'" (you'll need to make a registration
367
- and accept a license).
368
-
369
- Uncompress the archive in a proper location (this guide assumes
370
- that all the downloaded source code will be placed in the user home)
371
- and the enter the newly created folder
372
-
373
- cd /libecwj2-3.3
374
-
375
- Compile the code with the standard commands
376
-
377
- ./configure
378
-
379
- then
380
-
381
- make
382
-
383
- then
384
-
385
- sudo make install
386
-
387
- leave the folder
388
-
389
- cd ..
390
-
391
-
392
- 3.9.3. Step 3: download the MrSID binaries
393
- ==========================================
394
-
395
- Go to the LIZARDTECH web site http://www.lizardtech.com/ and follow the links
396
- "'download --> Developer SDKs'",
397
- then download the "'GeoExpress SDK for Linux (x86) - gcc 4.1 32-bit'"
398
- (you'll need to make a registration and accept a license).
399
-
400
- Uncompress the downloaded file. The resulting directory name should be similar to "Geo_DSDK-7.0.0.2167"
401
-
402
-
403
- 3.9.4. Step 4: compile and install the gdal libraries
404
- =====================================================
405
-
406
- Download the latest gdal source code
407
-
408
- svn checkout https://svn.osgeo.org/gdal/trunk/gdal gdal
409
-
410
- then copy a few files from the MrSID binaries folder to the folder with the gdal source code
411
- ('replace "USERNAME" with your actual account username')
412
-
413
- cp /home/USERNAME/Geo_DSDK-7.0.0.2167/include/*.* /home/USERNAME/gdal/frmts/mrsid/
414
-
415
- enter the gdal source code folder
416
-
417
- cd /gdal
418
-
419
- and run configure with a few specific parameters
420
-
421
- ./configure --without-grass --with-mrsid=../Geo_DSDK-7.0.0.2167 --without-jp2mrsid
422
-
423
- at the end of the configuration process you should read something like
424
-
425
- ...
426
- GRASS support: no
427
- ...
428
- ...
429
- ...
430
- ECW support: yes
431
- MrSID support yes
432
- ...
433
-
434
- then compile normally
435
-
436
- make
437
-
438
- and
439
-
440
- sudo make install
441
-
442
- finish the process by creating the necessary links to the most recent shared libraries
443
-
444
- sudo ldconfig
445
-
446
- at this point you may want to check if gdal was compiled correctly with MrSID and ECW
447
- support by issuing one (or both) of the following commands
448
-
449
- gdalinfo --formats | grep 'ECW'
450
-
451
- gdalinfo --formats | grep 'SID'
452
-
453
- leave the folder
454
-
455
- cd ..
456
-
457
-
458
- 3.9.5. Step 5: compile and install GRASS
459
- ========================================
460
-
461
- Before downloading and compile GRASS source code you need to install a few
462
- other libraries and programs. We can do this through apt
463
-
464
- sudo apt-get install flex bison libreadline5-dev libncurses5-dev lesstif2-dev \
465
- debhelper dpatch libtiff4-dev tcl8.4-dev tk8.4-dev fftw-dev xlibmesa-gl-dev \
466
- libfreetype6-dev autoconf2.13 autotools-dev libgdal1-dev proj libjpeg62-dev \
467
- libpng12-dev libpq-dev unixodbc-dev doxygen fakeroot cmake python-dev \
468
- python-qt4-common python-qt4-dev python-sip4 python2.5-dev sip4 libglew1.5-dev \
469
- libxmu6 \ libqt4-dev libgsl0-dev python-qt4 swig python-wxversion \
470
- python-wxgtk2.8 libwxgtk2.8-0 libwxbase2.8-0 tcl8.4-dev tk8.4-dev tk8.4 \
471
- libfftw3-dev libfftw3-3
472
-
473
- At this point we can get the GRASS source code: you may want to download it
474
- through svn or maybe you want just to download the latest available source code
475
- archive. For example the GRASS 6.4rc4 is available at
476
- http://grass.itc.it/grass64/source/grass-6.4.0RC4.tar.gz
477
-
478
- Uncompress the archive, enter the newly created folder and run configure with a few specific parameters
479
-
480
- CFLAGS="-fexceptions" ./configure \
481
- --with-tcltk-includes=/usr/include/tcl8.4 \
482
- --with-proj-share=/usr/share/proj \
483
- --with-gdal=/usr/local/bin/gdal-config \
484
- --with-python=/usr/bin/python2.5-config
485
-
486
- The additional gcc option -fexceptions is necessary to enable exceptions
487
- support in GRASS libraries. It is currently the only way to avoid QGIS crashes
488
- if a fatal error happens in GRASS library. See also
489
- http://trac.osgeo.org/grass/ticket/869
490
-
491
- Then as usual (it will take a while)
492
-
493
- make
494
-
495
- and
496
-
497
- sudo make install
498
-
499
- leave the folder
500
-
501
- cd ..
502
-
503
- you have now compiled and installed GRASS (also with the new wxpyhton interface) so you
504
- may want to give it a try
505
-
506
- grass64 -wxpython
507
-
508
-
509
- 3.9.6. Step 6: Compile and install QGIS
510
- =======================================
511
-
512
- As for GRASS you can obtain the QGIS source code from different sources as described
513
- in section 2 above. Once you have the sources, create a build directory in them:
514
-
515
- cd QGIS
516
- mkdir build
517
- cd build
518
-
519
- then run ccmake
520
-
521
- ccmake ..
522
-
523
- Press the "c" key to do an initial configure.
524
- Press the "c" again and the option "Press [g] to generate and exit" will appear.
525
- Press the "g" key to generate and exit.
526
-
527
- then as usual (it will take a while)
528
-
529
- make
530
-
531
- and
532
-
533
- sudo make install
534
-
535
- At the end of the process you should have QGIS and GRASS working with MrSID and ECW
536
- raster format support.
537
-
538
- To run QGIS just use this command
539
-
540
- qgis
541
-
542
-
543
313
4. Building on Windows
544
314
======================
545
315
0 commit comments