Compiling QGIS on Windows

Note: I am using Windows 10 for this guide.

First, we need to download and install some prerequisites: CMake, Cygwin, Git, OSGeo4W, and Ninja.

When installing CMake and Git, the default settings will work. When installing Cygwin, keep the “Root Directory” as C:\cygwin64 and install the bison, flex and git packages. Installing git within Cygwin allows us to use the current build number when compiling QGIS.

For OSGeo4W, you will want to start by selecting “Advanced Install”. Click “Next” and select “Install from Internet”. Click “Next” and keep the “Root Directory” as C:\OSGeo4W64.

Click “Next” and set the “Start menu name” to “OSGeo4W”.

Click “Next”. Setup a proxy if needed, otherwise, leave it set to “Direct Connection”. Click “Next” and select “” from the available sites. Click “Next” and proceed to install the following:


And that’s it for OSGeo4W.

For Ninja, simply unzip and place ninja.exe in the C:\OSGeo4W64\bin directory.

Next, download and install Visual Studio 2015. You don’t need the IDE to build QGIS, but the libraries you need to build QGIS for Windows are installed at this time.

Do a “Custom” install and select Visual C++ under “Programming Languages” and Tools (1.4.1) and Windows 10 SDK (10.0.14393) under “Windows and Web Development/Universal Windows App Development Tools”.

Click “Next” and finish the installation.

Note: If you run into an issue with installing the Windows 10 SDK (10.0.14393), download the SDK and install separately.

Once that’s done, save the following as QGIS-Dev.bat in the C:\OSGeo4W64 directory:

@echo off
set SOURCE=C:\Projects\QGIS
call "%SOURCE%\ms-windows\osgeo4w\msvc-env.bat" x86_64

Next, clone down the QGIS repository to C:\Projects\QGIS, then run the QGIS-Dev.bat file in the C:\OSGeo4W64 directory by double clicking it.

To build the QGIS without using Visual Studio, run the following in the Command Prompt that opens:

mkdir build
cd build
cmake -G Ninja ..

Now sit back, grab your favorite beverage and wait for the code to compile.

If you wish to use Visual Studio instead, run the following:

cd %SOURCE%\ms-windows\osgeo4w

Next, open C:\Projects\QGIS\ms-windows\osgeo4w\build-qgis-test-x86_64\qgis.sln in Visual Studio and wait for the project to load. Build the All_BUILD project when ready then go find something else to do for a while.

Once the build is complete, you are ready to run QGIS. Simply, right-click on the ALL_BUILD project and click “Properties”. Look for “Debugging” under the “Configuration” setting. Update the “Command” to C:\Projects\QGIS\ms-windows\osgeo4w\build-qgis-test-x86_64\output\bin\RelWithDebInfo\qgis.exe. Click “OK”.

You can now run QGIS by pressing the “Start Debugging” icon or hitting F5 on your keyboard. When prompted about “out of date” projects, just click “No”.

Last updated on: 12/03/2019

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.