Skip to content

Instantly share code, notes, and snippets.

@troopa81
Last active September 30, 2023 12:56
Show Gist options
  • Save troopa81/b43f96c20fdde2778ecdeaf8cf87684e to your computer and use it in GitHub Desktop.
Save troopa81/b43f96c20fdde2778ecdeaf8cf87684e to your computer and use it in GitHub Desktop.
My notes on how build QGIS on Windows with OSGEO4W v2

To build with Ninja

Download and install Cygwin : https://www.cygwin.com/setup-x86_64.exe Install it and and install the following packages : flex bison curl git unzip

Download and install last stable release of CMake : https://cmake.org/download/

I think we don't need to install git with Windows installer because we already have it with cygwin but I failed to clone https repo and I don't know which cygwin package a need to install.

Download Visual Studio 2019 Community : https://my.visualstudio.com/Downloads?q=visual%20studio%202019&wt.mc_id=o~msft~vscom~older-downloads Install the workload C++ Desktop development

Download and install OSGeo4w v2 : http://download.osgeo.org/osgeo4w/v2/osgeo4w-setup.exe

From a new cygwin console:

git clone https://github.com/jef-n/OSGeo4W.git
cd OSGeo4W/src/qgis-dev/osgeo4w
export OSGEO4W_REP=/cygdrive/C/OSGeo4W
# In order to set VCSDK correctly, take a look of the folder name in C:\Program Files (x86)\Windows Kits\10\Lib
export VCSDK=10.0.19041.0
# Comment line 112 to 116 of the package.sh file, associated to grass (I imagine there is something more to be done to make this lines work)
./package.sh

to start the program, you then need to copy the directory C:\cygwin64\home\Julien\OSGeo4W\src\qgis-dev\osgeo4w to C:\cygwin64\home\Julien\OSGeo4W\src\qgis-dev\osgeo4w\osgeo4w and modify qgis-dev.bat script in bon dir to change the start line with this

start "QGIS" /B "%OSGEO4W_ROOT%\apps\qgis-dev\bin\qgis.exe" %*

To build and debug within Visual Studio

In package.sh, replace Ninja with Visual Studio 16 2019 in the CMake command call and add "exit 0" just after, then call package.sh script.

Then from a new cmd interface

cd C:\cygwin64\home\Julien\OSGeo4W\src\qgis-dev\osgeo4w\build
call ../osgeo4w/bin/o4w_env.bat
"C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\Common7\IDE\devenv.exe" qgis.sln

You can now build your QGIS target inside Visual Studio 2019

@Guts
Copy link

Guts commented Mar 28, 2022

Thanks you a lot @troopa81!

Building QGIS on Windows is definitively lacking of a good and shared documentation! Your notes are enlightening a dark box!

@Guts
Copy link

Guts commented Mar 28, 2022

@jef-n
Copy link

jef-n commented Mar 28, 2022

Hmm. I'm used to reuse some parts of this one: https://github.com/qgis/QGIS/blob/master/.ci/azure-pipelines/azure-pipelines.yml. Which one is preferable?

The one I pointed at. azure-pipelines is older and predates OSGeo4W v2. However both are not actually used.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment