==Building with Microsoft Visual Studio== This section describes how to build QGIS using Visual Studio on Windows. This is currently also who the binary QGIS packages are made (earlier versions used MinGW). This section describes the setup required to allow Visual Studio to be used to build QGIS. ===Visual C++ Express Edition=== The free (as in free beer) Express Edition installer is available under: http://download.microsoft.com/download/d/c/3/dc3439e7-5533-4f4c-9ba0-8577685b6e7e/vcsetup.exe The optional products are not necessary. In the process the Windows SDKs for Visual Studio 2008 will also be downloaded and installed. You also need the Microsoft Windows ServerŪ 2003 R2 Platform SDK (for setupapi): http://download.microsoft.com/download/f/a/d/fad9efde-8627-4e7a-8812-c351ba099151/PSDK-x86.exe You only need Microsoft Windows Core SDK / Build Environment (x86 32-Bit). ===Other tools and dependencies=== Download and install following packages: || Tool | Website | | CMake | http://www.cmake.org/files/v2.8/cmake-2.8.2-win32-x86.exe | | Flex | http://gnuwin32.sourceforge.net/downlinks/flex.php | | Bison | http://gnuwin32.sourceforge.net/downlinks/bison.php | | SVN | http://sourceforge.net/projects/win32svn/files/1.6.13/Setup-Subversion-1.6.13.msi/download | | OSGeo4W | http://download.osgeo.org/osgeo4w/osgeo4w-setup.exe | OSGeo4W does not only provide ready packages for the current QGIS release and nightly builds of the trunk, but also offers most of the dependencies needs to build it. For the QGIS build you need to install following packages from OSGeo4W (select //Advanced Installation//): - expat - fcgi - gdal17 - grass - gsl-devel - iconv - pyqt4 - qt4-devel - qwt5-devel-qt4 - sip - This will also select packages the above packages depend on. Additionally QGIS also needs the include file ``unistd.h``, which normally doesn't exist on Windows. It's shipped with Flex/Bison in ``GnuWin32\include`` and needs to be copied into the ``VC\include`` directory of your Visual C++ installation. Earlier versions of this document also covered how to build all above dependencies. If you're interested in that, check the history of this page in the Wiki or the SVN repository. === Setting up the Visual Studio project with CMake === To start a command prompt with an environment that both has the VC++ and the OSGeo4W variables create the following batch file (assuming the above packages were installed in the default locations): ``` @echo off path %SYSTEMROOT%\system32;%SYSTEMROOT%;%SYSTEMROOT%\System32\Wbem;%PROGRAMFILES%\CMake 2.8\bin;%PROGRAMFILES%\subversion\bin;%PROGRAMFILES%\GnuWin32\bin set PYTHONPATH= set VS90COMNTOOLS=%PROGRAMFILES%\Microsoft Visual Studio 9.0\Common7\Tools\ call "%PROGRAMFILES%\Microsoft Visual Studio 9.0\VC\vcvarsall.bat" x86 set INCLUDE=%INCLUDE%;%PROGRAMFILES%\Microsoft Platform SDK for Windows Server 2003 R2\include set LIB=%LIB%;%PROGRAMFILES%\Microsoft Platform SDK for Windows Server 2003 R2\lib set OSGEO4W_ROOT=C:\OSGeo4W call "%OSGEO4W_ROOT%\bin\o4w_env.bat" @set GRASS_PREFIX=c:/OSGeo4W/apps/grass/grass-6.4.0 @set INCLUDE=%INCLUDE%;%OSGEO4W_ROOT%\apps\gdal-17\include;%OSGEO4W_ROOT%\include @set LIB=%LIB%;%OSGEO4W_ROOT%\apps\gdal-17\lib;%OSGEO4W_ROOT%\lib @cmd ``` Start the batch file and on the command prompt checkout the QGIS source from svn to the source directory ``qgis-trunk``: ``` svn co https://svn.osgeo.org/qgis/trunk/qgis qgis-trunk ``` Create a 'build' directory somewhere. This will be where all the build output will be generated. Now run ``cmake-gui`` and in the //Where is the source code:// box, browse to the top level QGIS directory. In the //Where to build the binaries:// box, browse to the 'build' directory you created. Hit ``Configure`` to start the configuration and select ``Visual Studio 9 2008`` and keep ``native compilers`` and click ``Finish``. The configuration should complete without any further questions and allow you to click ``Generate``. Now close ``cmake-gui`` and continue on the command prompt by starting ``vcexpress``. Use File / Open / Project/Solutions and open the qgis-x.y.z.sln File in your project directory. Change ``Solution Configuration`` from ``Debug`` to ``RelWithDebInfo`` (Release with Debug Info) or ``Release`` before you build QGIS using the ALL_BUILD target (otherwise you need debug libraries that are not included). After the build completed you should install QGIS using the INSTALL target. Install QGIS by building the INSTALL project. By default this will install to c:\Program Files\qgis (this can be changed by changing the CMAKE_INSTALL_PREFIX variable in cmake-gui). You will also either need to add all the dependency DLLs to the QGIS install directory or add their respective directories to your PATH. === Packaging === To create a windows 'all in one' standalone package ''under ubuntu'' (yes you read correctly) do the following: ``` sudo apt-get install nsis ``` Now ``` cd qgis/ms-windows/osgeo4w ``` And run the nsis creation script: ``` creatensis.pl ``` When the script completes, it should have created a QGIS installer executable in the ms-windows directory. === Osgeo4w packaging === The actual packaging process is currently not documented, for now please take a look at: //ms-windows/osgeo4w/package.cmd//