1
1
QGIS
2
2
Building QGIS from source - step by step
3
- Friday May 11 , 2018
3
+ Wednesday June 20 , 2018
4
4
5
5
6
- Last Updated: Friday May 11 , 2018
7
- Last Change : Friday May 11 , 2018
6
+ Last Updated: Wednesday June 20 , 2018
7
+ Last Change : Wednesday June 20 , 2018
8
8
9
9
10
10
1. Introduction
@@ -430,12 +430,11 @@ To enable debug prints for the current user, execute:
430
430
4.1. Building with Microsoft Visual Studio
431
431
==========================================
432
432
433
- This section describes how to build QGIS using Visual Studio on Windows. This
434
- is currently also how the binary QGIS packages are made (earlier versions used
435
- MinGW).
433
+ This section describes how to build QGIS using Visual Studio (MSVC) 2015 on Windows.
434
+ This is currently also how the binary QGIS packages are made (earlier versions used MinGW).
436
435
437
436
This section describes the setup required to allow Visual Studio to be used to
438
- build QGIS.
437
+ build QGIS.
439
438
440
439
441
440
4.1.1. Visual C++ Community Edition
@@ -457,10 +456,6 @@ Download and install following packages:
457
456
| OSGeo4W | http://download.osgeo.org/osgeo4w/osgeo4w-setup-x86.exe (32bit) or http://download.osgeo.org/osgeo4w/osgeo4w-setup-x86_64.exe (64bit) |
458
457
| ninja | https://github.com/ninja-build/ninja/releases/download/v1.7.2/ninja-win.zip |
459
458
460
- OSGeo4W does not only provide ready packages for the current QGIS release and
461
- nightly builds of master, but also offers most of the dependencies needs to
462
- build it.
463
-
464
459
For the QGIS build you need to install following packages from cygwin:
465
460
466
461
- bison
@@ -469,19 +464,22 @@ For the QGIS build you need to install following packages from cygwin:
469
464
470
465
and from OSGeo4W (select Advanced Installation):
471
466
472
- - qgis-rel -deps
467
+ - qgis-dev -deps
473
468
474
469
This will also select packages the above packages depend on.
475
470
476
- If you install other packages, this might cause issues. Particularly, make sure
477
- not to install the msinttypes package. It installs a stdint.h file in
478
- OSGeo4W[64]\include, that conflicts with Visual Studio own stdint.h, which for
479
- example breaks the build of the virtuallayer provider.
471
+ If you install other packages, this might cause issues. Particularly, make sure
472
+ not to install the msinttypes package. It installs a stdint.h file in
473
+ OSGeo4W[64]\include, that conflicts with Visual Studio own stdint.h, which for
474
+ example breaks the build of the virtual layer provider.
480
475
481
476
Earlier versions of this document also covered how to build all above
482
477
dependencies. If you're interested in that, check the history of this page in the Wiki
483
478
or the SVN repository.
484
479
480
+ ninja:
481
+ copy ninja.exe to d:\OSGeo4W64\bin\
482
+
485
483
486
484
4.1.3. Setting up the Visual Studio project with CMake
487
485
======================================================
@@ -496,71 +494,78 @@ variables create the following batch file (assuming the above packages were
496
494
installed in the default locations):
497
495
498
496
@echo off
499
- set OSGEO4W_ROOT=C:\OSGeo4W
500
- call "%OSGEO4W_ROOT%\bin\o4w_env.bat"
501
- call "%OSGEO4W_ROOT%\bin\py3_env.bat"
502
- call "%OSGEO4W_ROOT%\bin\qt5_env.bat"
503
-
504
- set O4W_ROOT=%OSGEO4W_ROOT:\=/%
505
- set LIB_DIR=%O4W_ROOT%
506
-
507
- call "C:\Program Files\Microsoft Visual Studio 14.0\VC\vcvarsall.bat" amd64
508
- path %path%;C:\Program Files\Microsoft Visual Studio 14.0\VC\bin
509
-
510
- path %PATH%;C:\Program Files\CMake\bin;c:\cygwin\bin
511
-
512
- @set GRASS_PREFIX=c:/OSGeo4W/apps/grass/grass-7.2.1
513
- @set INCLUDE=%INCLUDE%;%OSGEO4W_ROOT%\include
514
- @set LIB=%LIB%;%OSGEO4W_ROOT%\lib;%OSGEO4W_ROOT%\lib
515
-
516
- set LIB=%LIB%;%OSGEO4W_ROOT%\apps\Qt5\lib;%OSGEO4W_ROOT%\lib
517
- set INCLUDE=%INCLUDE%;%OSGEO4W_ROOT%\apps\Qt5\include;%OSGEO4W_ROOT%\include
518
-
497
+ call X:\src\qgis\ms-windows\osgeo4w\msvc-env.bat x86_64
519
498
@cmd
520
499
521
- Start the batch file and on the command prompt checkout the QGIS source from
500
+ Save the batch file as d:\OSGeo4W64\OSGeo4W-dev.bat and run it.
501
+ On the command prompt checkout the QGIS source from
522
502
git to the source directory QGIS:
523
503
524
504
git clone git://github.com/qgis/QGIS.git
525
505
526
- Create a 'build' directory somewhere. This will be where all the build output
527
- will be generated.
506
+ Using configonly.cmd to create the MSVC solution file:
507
+ We will be using the file ms-windows/osgeo4w/configonly.cmd to create an MSVC solution file.
508
+ There are a few options for a solution file, following are the options: ninja, native MSVC.
509
+ The advantage of using native MSVC solution is that you can find the root of build problems much easily.
510
+ configonly.cmd is meant to create a configured build directory with a MSVC solution file:
511
+
512
+ ```
513
+ configonly.cmd
514
+ ```
515
+
516
+ Compiling QGIS with MSVC:
517
+ We will need to run MSVC with all the environment variables set, thus we will run it as follows:
518
+ Run the batch file OSGeo4W-dev.bat you created before. On the command prompt run: devenv
519
+ From MSVC, open the solution file
520
+ d:\OSGeo4W64\QGIS\ms-windows\osgeo4w\build-qgis-test-x86_64\qgis2.99.0.sln
521
+ Try to build the solution go grab a cup of tea, it may take a (while).
522
+ If it fails, run it again and again until there are [hopefully] no errors.
523
+
524
+ Running QGIS from within MSVC:
525
+ Edit the properties of the project ALL_BUILD:
526
+ Debugging -> Command -> D:\OSGeo4W64\QGIS\ms-windows\osgeo4w\build-qgis-test-x86_64\output\bin\RelWithDebInfo\qgis.exe
527
+ Run.
528
+ Ignore the "These projects are out of date" message, it appeares even if no files were was changed.
529
+
530
+ Old alternative method that might still work using cmake-gui:
531
+ Create a 'build' directory somewhere. This will be where all the build output
532
+ will be generated.
528
533
529
- Now run cmake-gui (still from cmd) and in the Where is the source code:
530
- box, browse to the top level QGIS directory.
534
+ Now run cmake-gui (still from cmd) and in the Where is the source code:
535
+ box, browse to the top level QGIS directory.
531
536
532
- In the Where to build the binaries: box, browse to the 'build' directory you
533
- created.
537
+ In the Where to build the binaries: box, browse to the 'build' directory you
538
+ created.
534
539
535
- If the path to bison and flex contains blanks, you need to use the short name
536
- for the directory (i.e. C:\Program Files should be rewritten to
537
- C:\Progra~n, where n is the number as shown in `dir /x C:\``).
540
+ If the path to bison and flex contains blanks, you need to use the short name
541
+ for the directory (i.e. C:\Program Files should be rewritten to
542
+ C:\Progra~n, where n is the number as shown in `dir /x C:\``).
538
543
539
- Verify that the 'BINDINGS_GLOBAL_INSTALL' option is not checked, so that python
540
- bindings are placed into the output directory when you run the INSTALL target.
544
+ Verify that the 'BINDINGS_GLOBAL_INSTALL' option is not checked, so that python
545
+ bindings are placed into the output directory when you run the INSTALL target.
541
546
542
- Hit Configure to start the configuration and select Visual Studio 9 2008
543
- and keep native compilers and click Finish.
547
+ Hit Configure to start the configuration and select Visual Studio 9 2008
548
+ and keep native compilers and click Finish.
544
549
545
- The configuration should complete without any further questions and allow you to
546
- click Generate.
550
+ The configuration should complete without any further questions and allow you to
551
+ click Generate.
547
552
548
- Now close cmake-gui and continue on the command prompt by starting
549
- vcexpress. Use File / Open / Project/Solutions and open the
550
- qgis-x.y.z.sln File in your project directory.
553
+ Now close cmake-gui and continue on the command prompt by starting
554
+ vcexpress. Use File / Open / Project/Solutions and open the
555
+ qgis-x.y.z.sln File in your project directory.
551
556
552
- Change Solution Configuration from Debug to RelWithDebInfo (Release
553
- with Debug Info) or Release before you build QGIS using the ALL_BUILD
554
- target (otherwise you need debug libraries that are not included).
557
+ Change Solution Configuration from Debug to RelWithDebInfo (Release
558
+ with Debug Info) or Release before you build QGIS using the ALL_BUILD
559
+ target (otherwise you need debug libraries that are not included).
555
560
556
- After the build completed you should install QGIS using the INSTALL target.
561
+ After the build completed you should install QGIS using the INSTALL target.
557
562
558
- Install QGIS by building the INSTALL project. By default this will install to
559
- c:\Program Files\qgis<version> (this can be changed by changing the
560
- CMAKE_INSTALL_PREFIX variable in cmake-gui).
563
+ Install QGIS by building the INSTALL project. By default this will install to
564
+ c:\Program Files\qgis<version> (this can be changed by changing the
565
+ CMAKE_INSTALL_PREFIX variable in cmake-gui).
561
566
562
- You will also either need to add all the dependency DLLs to the QGIS install
563
- directory or add their respective directories to your PATH.
567
+ You will also either need to add all the dependency DLLs to the QGIS install
568
+ directory or add their respective directories to your PATH.
564
569
565
570
566
571
4.1.4. Packaging
@@ -600,7 +605,7 @@ Now create a package.
600
605
601
606
./quickpackage.sh
602
607
603
- After this you should now have a nsis installer containing your own build
608
+ After this you should now have a nsis installer containing your own build
604
609
of QGIS and all dependencies needed to run it on a windows machine.
605
610
606
611
0 commit comments