BuildWindowsGisinternals - Maproom/qmapshack GitHub Wiki

Prev (GDAL support for additional map formats) | Home | Manual | Index | (Ubuntu-14.04) Next


Build QMapShack for Windows using GISInternals

Table of contents


Introduction

A build procedure for QMapShack and QMapTool (QMS) on Windows is described here and here. Using this procedure, all packages on which QMS depends (GDAL, proj, zlib, ...) must be built individually from their sources (assuming that a suitable precompiled package is not available). If additional GDAL plugins (e.g. for the ECW format) are to be used in QMS, separate build steps are required for these plugins. The user must ensure that all required packages (including Qt5 and optional GDAL plugins) are built with compatible compiler versions. Depending on the GDAL version and the GDAL build configuration, building the plugins using this procedure may fail for various reasons.

This page describes a QMS build procedure for Windows based on a complete and precompiled GDAL build environment package provided by GISInternals. This procedure has several advantages over the one just described:

  • GISInternals packages are provided for different versions of Microsoft VisualStudio (MSVC).

  • GISInternals packages are provided for different GDAL versions.

  • GISInternals packages support many GDAL plugins, including those for the widely used ECW, MrSID, PDF, KMZ, OZIExplorer, and other raster map plugins (main reason for using GISInternals).

  • GISInternals packages provide precompiled library and header files for all GDAL dependencies and plugins. This implies that there is no need to download Hexagon ERDAS ECW/JP2 SDK or other sources.

  • GISInternals packages provide all necessary DLL files. Build/compile steps for GISInternals packages are not required. Remark: Building one of the GISInternals packages would require the preliminary download of the sources of some of the dependency packages and/or adjusted settings in the GISInternals makefile and is not recommended.

  • All QMS dependencies except for Qt5, Routino, and QuaZip are also dependencies of GDAL and are therefore available in precompiled form. Remark: Use the Dependency Walker to identify these dependencies.

  • Only the Routino and QuaZip dependencies of QMS for which no precompiled build environments are available have to be built separately. This greatly reduces the number of build/compiler runs required before building QMS.

    Routino doesn't depend on any of the GDAL dependencies.

    QuaZip depends on zlib which is also a GDAL dependency.

  • All individual packages within a GISInternals package are built with the same compiler version. Runtime libraries compiled with MSVC 2015 and later versions of the compiler are binary-compatible. This gives some freedom in choosing the MSVC version as well as the Qt5, the GISInternals, and other package versions. To meet the compiler compatibility requirements QMS should be compiled with the latest MSVC version and the latest redistributable version possible.

A disadvantage of this approach is that the user is bound to the software versions chosen by GISInternals.

Get required packages

  1. Install, if not yet done, MSVC 2022 or update to this version. Compiling QMS with this MSVC version ensures compatibility with dependency packages compiled with MSVC 2019, 2017, or 2015 versions.

  2. Install, if not yet done, the latest Microsoft Visual C++ Redistributable.

  3. Install, if not yet done, a Qt5 version for one of the compatible MSVC versions (example: Qt 5.15.2 or newer).

    1. Download the Qt5 online installer qt-unified-windows-x64-4.5.1-online.exe from https://download.qt.io/official_releases/online_installers
    2. Launch the online installer
    3. Register
    4. Follow the next steps
    5. Select user-defined installation
    6. Select at least the prebuilt components Qt - Qt 5.15.2 for MSVC 2019 64-bit and Qt Web Engine for download
    7. Follow next steps to download the selected components (this includes necessary library and header files)
  4. Download the QuaZip sources.

  5. Goto the GISInternals Development Kits page and select an MSVC version for the x64 architecture.

    1. Click the corresponding development release package (example: release-1930-x64-dev) and download its ZIP file.
    2. Unpack the downloaded ZIP file. To avoid DLL version conflicts delete the files .\release-1930-x64\bin\proj_?_?.dll with the exception of the newest/latest one.

    Remarks:

    • In this GISInternals link, the latest available GDAL version is used. Its version number can be found in the file .\release-1930-x64\doc\gdal_version.txt.
    • Other GDAL versions can be found when starting from GISInternals stable or other branches.
    • The versions of included additional dependency packages and their download locations can be found near the end of the file config.opt in the root directory.
    • A list of supported GDAL formats can be found in the file .\release-1930-x64\doc\gdal_formats.txt.
  6. Download the QMS sources.

    To ensure GDAL plugin support comment out the line qunsetenv("GDAL_DRIVER_PATH"); in the QMS source files

    • .\src\qmapshack\setup\CAppSetupWin.cpp and
    • .\src\qmaptool\setup\CAppSetupWin.cpp.

Build QMS

  1. Configure and build the Routino library using the mingw64 toolchain.

  2. Use the Visual Studio 17 2022 generator for the x64 architecture to compile QuaZip and QMS with the CMake build system. The following description is based on the use of the CMake command-line tool. All CMake configuration settings are saved in a configuration file CfgGisinternals.cfg the content of which is discussed later on this page. The information given in this configuration file can easily be applied when working with the CMake-gui.

  3. Configure and build the QuaZip library (without BZip2). QuaZip depends on zlib which should be taken from the GISInternals package using its DLL filename convention.

    1. Adjust the settings for QuaZip, Qt5, and zlib in the CMake configuration file for QuaZip.
    2. Open the MSVC x64 Native Tools Command Prompt.
    3. Goto the QuaZip root directory
    4. Run md build
    5. Run cd build
    6. Run cmake -G "Visual Studio 17 2022" -A x64 -S .. -B . -LA -DPKG=QUAZIP -C <your_path_to_cfg>\CfgGisinternals.cfg
    7. Check that the configuration and generation of the build system has been correct (look for output lines -- Configuring done and -- Generating done and check variable values)
    8. Run cmake --build . --config Release -j8
    9. Run cmake --build . --config Release -j8 --target install
  4. Configure and build QMS.

    1. Adjust the settings for Routino, QuaZip, and Qt5 in the CMake configuration file for QMS.
    2. Adjust the settings for GDAL and its dependencies (proj, zlib, ...) in the CMake configuration file for QMS to the appropriate subdirectories of the unpacked GISInternal package (release-1930-x64).
    3. Open the MSVC x64 Native Tools Command Prompt.
    4. Goto the QMS root directory
    5. Run md build
    6. Run cd build
    7. Run cmake -G "Visual Studio 17 2022" -A x64 -S .. -B . -LA -DPKG=QMS -C <your_path_to_cfg>\CfgGisinternals.cfg
    8. Check that the configuration and generation of the build system has been correct (look for output lines -- Configuring done and -- Generating done and check variable values)
    9. Run cmake --build . --config Release -j8
  5. Copy all required files to the ...\QMS\msvc_64\Files directory before starting QMS for the first time.

    The ...\QMS\msvc_64\copyfiles.bat file in the QMS distribution can serve as a basis for this copy step, but it needs to be adapted as it depends on version numbers and some unsuitable filenames. An example of a modified copyfiles.bat is given at the end of this page.

  6. Set the GDAL_DRIVER_PATH environment variable to ...\QMS\msvc_64\Files\gdalplugins

  7. Set the PROJ_LIB environment variable to ...\QMS\QMapShack\msvc_64\Files\share\proj

Remarks:

  • If a projection error occurs when starting QMS, the contents of the Files\share\proj directory is incomplete. Restarting QMS after such a projection error with an updated share\proj directory may fail due to a corrupted QMS INI file. In the Views section of the INI file the projections may be missing or incomplete. In this case, delete the Views section of the INI file and restart QMS.
  • Version numbers of the dependencies used in GISInternals can be found in the files ...\release-1930-x64\doc\gdal_deps.txt and ...\release-1930-x64\doc\gdal_version.txt.
  • Call gdalinfo --formats to see all map formats (plugins) supported by GDAL. Among others, ECW, MrSID, and MBTILES are available.
  • With the described use of GISInternals MySQL databases can be accessed in QMS.

Configuration examples

CMake configuration file

The following file is an example CMake configuration file for building the QuaZip and QMS build systems. Set the PKG parameter to QUAZIP resp. QMS to select the correct application.

# CMake example settings for QMS and QuaZip compilation 

# Quazip: Run from build dir: 
#    cmake  -G "Visual Studio 17 2022" -A x64 -S .. -B . -LA -DPKG=QUAZIP -C d:\<your_cfg_path>\CfgGisinternals.cfg

# QMS:    Run from build dir: 
#    cmake  -G "Visual Studio 17 2022" -A x64 -S .. -B . -LA -DPKG=QMS    -C d:\<>your_cfg_path\CfgGisinternals.cfg

# general settings: ---------------------------------------------------------------
set(QT5_VER              "5.15.2"   CACHE STRING "used Qt5 version"          FORCE)
set(QT_MSVC64_VER        "2019_64"  CACHE STRING "used MSVC version in Qt"   FORCE)
set(QUAZIP_VER           "1.4"      CACHE STRING "used QUAZIP version"       FORCE)
set(ROUTINO_VER          "3.3.3"    CACHE STRING "used ROUTINO version"      FORCE)
set(GISINTERNALS_VER     "1930"     CACHE STRING "used gisinternals version" FORCE)

cmake_policy(SET CMP0054 NEW)

set(QMSDIR           "d:/QtProjects/QMS"          CACHE STRING "basis location of all packages" FORCE)
set(GISINTERNALS_DEV_PATH "${QMSDIR}/gisinternals/${GISINTERNALS_VER}/release-${GISINTERNALS_VER}-x64" CACHE PATH "gisinternals release path" FORCE)

set(ZLIB_INCLUDE_DIR     ${GISINTERNALS_DEV_PATH}/include CACHE PATH "zlib include dir" FORCE)

set(CMAKE_BUILD_TYPE     "Release" CACHE STRING "compile release only" FORCE)

# QMS-specific settings (${PKG} from cmake command-line!): ------------------------------------------------------------
if(${PKG} STREQUAL "QMS")
    set(ROUT             "routino/routino-${ROUTINO_VER}" CACHE STRING "routino bas dir" FORCE)

    set(CMAKE_INSTALL_PREFIX ${QMSDIR}/QMapShack/install CACHE PATH "template for INSTALL DIR" FORCE)

    # see: https://docs.microsoft.com/en-us/cpp/error-messages/compiler-warnings/compiler-warning-level-3-c4996?view=msvc-170
    set(CMAKE_CXX_FLAGS "/wd4996 /wd4101 /wd4005 /wd4003 ${CMAKE_CXX_FLAGS}" CACHE STRING "suppress some QMS compiler warnings" FORCE)

    set(Qt5Widgets_DIR       "d:/Qt/5.12.3/${QT5_VER}/msvc${QT_MSVC64_VER}/lib/cmake/Qt5Widgets" CACHE PATH "Qt5Widgets dir" FORCE)
    set(QT_DEV_PATH          "d:/Qt/5.12.3/${QT5_VER}/msvc${QT_MSVC64_VER}" CACHE PATH "Qt5 base dir for given MSVC version" FORCE)

    set(QuaZip-Qt5_DIR       "${QMSDIR}/quazip/quazip-${QUAZIP_VER}/install/lib/cmake/QuaZip-Qt5-${QUAZIP_VER}" CACHE PATH "Quazip lib dir" FORCE)
    set(QUAZIP_DEV_PATH      "${QMSDIR}/quazip/quazip-${QUAZIP_VER}/install" CACHE PATH "Quazip install dir" FORCE)
    set(QUAZIP_INCLUDE_DIR   "${QMSDIR}/quazip/quazip-${QUAZIP_VER}/install/include" CACHE PATH "Quazip include dir" FORCE)
    set(ROUTINO_DEV_PATH     "${QMSDIR}/${ROUT}/install" CACHE PATH "Routino install dir" FORCE)

    set(GDAL_DEV_PATH ${GISINTERNALS_DEV_PATH} CACHE PATH "gisinternals dev path" FORCE)
    set(JPEG_DEV_PATH ${GISINTERNALS_DEV_PATH} CACHE PATH "gisinternals dev path" FORCE)

    set(PROJ_DEV_PATH ${GISINTERNALS_DEV_PATH} CACHE PATH "gisinternals dev path" FORCE)
    set(PROJ_INCLUDE_DIR     ${GISINTERNALS_DEV_PATH}/include/proj9      CACHE PATH     "no docu" FORCE)
    set(LIBPROJ_LIBRARY      "${GISINTERNALS_DEV_PATH}/lib/proj9.lib"    CACHE FILEPATH "no docu" FORCE)

    set(ZLIB_ROOT ${GISINTERNALS_DEV_PATH} CACHE PATH "gisinternals dev path" FORCE)
    set(ZLIB_LIBRARY         "${GISINTERNALS_DEV_PATH}/lib/zlib.lib" CACHE FILEPATH "zlib lib name" FORCE)

# Quazip-specific settings: ----------------------------------------------------------------
elseif(${PKG} STREQUAL "QUAZIP")

    set(QUAZIP               "quazip/quazip-${QUAZIP_VER}"  CACHE STRING "Quazip base dir"            FORCE)
    set(QUAZIP_ENABLE_TESTS  OFF                            CACHE BOOL   "Don't prepare QuaZip tests" FORCE)
    set(QUAZIP_USE_QT_ZLIB   OFF                            CACHE BOOL   "Use zlib from GISInternals" FORCE)
    set(QUAZIP_QT_MAJOR_VERSION 5                           CACHE STRING "Use Qt5" FORCE)
    set(QUAZIP_BZIP2_STDIO   OFF                            CACHE BOOL   "Don't use bzip2" FORCE)
    set(QUAZIP_BZIP2         OFF                            CACHE BOOL   "Don't use bzip2" FORCE)

    set(CMAKE_INSTALL_PREFIX ${QMSDIR}/${QUAZIP}/install    CACHE PATH   "Quazip install dir" FORCE)

    set(QT_DIR               "d:/Qt/5.12.3/${QT5_VER}/msvc${QT_MSVC64_VER}/lib/cmake/Qt5" CACHE PATH "Qt5 base dir" FORCE)
    set(Qt5_DIR              "${QT_DIR}" CACHE PATH "Qt5 base dir" FORCE)

    set(ZLIB_LIBRARY_RELEASE "${GISINTERNALS_DEV_PATH}/lib/zlib.lib" CACHE FILEPATH "zlib library name used in GISInternals" FORCE)

endif()

Adapted file copyfiles.bat

Example of a possible modification of the QMS file ...\QMS\msvc_64\copyfiles.bat for files taken from the GISInternals package:

rem Batch file to copy necessary files for QMS
rem Please adapt environment variables in section 1) to your system

rem Section 1.) Define path to Qt, MSVC, .... installations

set QMSI_QMS_PATH=d:\QtProjects\QMS
set QMSI_GIS_PATH=d:\QtProjects\QMS\gisinternals\1930\release-1930-x64
set QMSI_QT_PATH="d:\Qt\5.12.3\5.15.2\msvc2019_64"
set QMSI_VCREDIST_PATH="c:\Program Files\Microsoft Visual Studio\2022\Community\VC\Redist\MSVC\14.34.31931"
set QMSI_ROUT_PATH="d:\QtProjects\QMS\routino\routino-3.3.3\install"
set QMSI_MGW6_PATH="D:\msys\opt\windows_64\bin"
set QMSI_QUAZIP_PATH="d:\QtProjects\QMS\quazip\quazip-1.4\install"
set QMSI_BUILD_PATH="d:\QtProjects\QMS\QMapShack\Build"

rem Section 2.) Copy Files
del /s/q Files
mkdir Files
cd Files

rem Section 2.1) Copy Qt files
rem Note: Qt5WebEngine deployment is super crazy - 
rem see https://doc.qt.io/qt-5.12/qtwebengine-deploying.html
copy %QMSI_QT_PATH%\bin\assistant.exe
copy %QMSI_QT_PATH%\bin\Qt5Core.dll
copy %QMSI_QT_PATH%\bin\Qt5Gui.dll
copy %QMSI_QT_PATH%\bin\Qt5Help.dll
copy %QMSI_QT_PATH%\bin\Qt5Multimedia.dll
copy %QMSI_QT_PATH%\bin\Qt5MultimediaWidgets.dll
copy %QMSI_QT_PATH%\bin\Qt5Network.dll
copy %QMSI_QT_PATH%\bin\Qt5OpenGL.dll
copy %QMSI_QT_PATH%\bin\Qt5Positioning.dll
copy %QMSI_QT_PATH%\bin\Qt5PrintSupport.dll
copy %QMSI_QT_PATH%\bin\Qt5Qml.dll
copy %QMSI_QT_PATH%\bin\Qt5QmlModels.dll
copy %QMSI_QT_PATH%\bin\Qt5Quick.dll
copy %QMSI_QT_PATH%\bin\Qt5QuickWidgets.dll
copy %QMSI_QT_PATH%\bin\Qt5Sensors.dll
copy %QMSI_QT_PATH%\bin\Qt5Sql.dll
copy %QMSI_QT_PATH%\bin\Qt5Svg.dll
copy %QMSI_QT_PATH%\bin\Qt5WebChannel.dll
copy %QMSI_QT_PATH%\bin\Qt5WebEngine.dll
copy %QMSI_QT_PATH%\bin\Qt5WebEngineCore.dll
copy %QMSI_QT_PATH%\bin\Qt5WebEngineWidgets.dll
copy %QMSI_QT_PATH%\bin\QtWebEngineProcess.exe
copy %QMSI_QT_PATH%\bin\Qt5Widgets.dll
copy %QMSI_QT_PATH%\bin\Qt5Xml.dll
copy %QMSI_QT_PATH%\bin\libEGL.dll
copy %QMSI_QT_PATH%\bin\libGLESv2.dll
mkdir imageformats
cd imageformats
copy %QMSI_QT_PATH%\plugins\imageformats\qgif.dll
copy %QMSI_QT_PATH%\plugins\imageformats\qjpeg.dll
copy %QMSI_QT_PATH%\plugins\imageformats\qsvg.dll
copy %QMSI_QT_PATH%\plugins\imageformats\qtiff.dll
copy %QMSI_QT_PATH%\plugins\imageformats\qico.dll
copy %QMSI_QT_PATH%\plugins\imageformats\qtga.dll
cd ..
mkdir sqldrivers
cd sqldrivers
copy %QMSI_QT_PATH%\plugins\sqldrivers\qsqlite.dll
copy %QMSI_QT_PATH%\plugins\sqldrivers\qsqlmysql.dll
copy %QMSI_QT_PATH%\plugins\sqldrivers\qsqlodbc.dll
copy %QMSI_QT_PATH%\plugins\sqldrivers\qsqlpsql.dll
cd ..
mkdir platforms
cd platforms
copy %QMSI_QT_PATH%\plugins\platforms\qwindows.dll
cd ..
mkdir printsupport
cd printsupport
copy %QMSI_QT_PATH%\plugins\printsupport\windowsprintersupport.dll
cd ..
rem Qt translations
rem Qt5: see http://doc.qt.io/qt-5/linguist-programmers.html
mkdir translations
copy %QMSI_QT_PATH%\translations\qtbase_??.qm translations
rem Qt5WebEngine translations
cd translations
mkdir qtwebengine_locales
copy %QMSI_QT_PATH%\translations\qtwebengine_locales\*.pak qtwebengine_locales
cd ..
rem rem Qt5WebEngine resources
mkdir resources
copy %QMSI_QT_PATH%\resources\*.* resources

rem section 2.2.5) Routino
copy %QMSI_ROUT_PATH%\lib\routino.dll
copy %QMSI_ROUT_PATH%\bin\planetsplitter.exe
copy %QMSI_MGW6_PATH%\libwinpthread-1.dll
copy %QMSI_MGW6_PATH%\libz-1.dll
xcopy %QMSI_ROUT_PATH%\xml routino-xml /s /i

rem section 2.2.7) QuaZip
copy %QMSI_QUAZIP_PATH%\bin\quazip1-qt5.dll

rem section 2.4) Copy QMapShack Files
copy %QMSI_BUILD_PATH%\bin\Release\qmapshack.exe
copy %QMSI_BUILD_PATH%\bin\Release\qmaptool.exe
copy %QMSI_BUILD_PATH%\bin\Release\qmt_map2jnx.exe
copy %QMSI_BUILD_PATH%\bin\Release\qmt_rgb2pct.exe
copy %QMSI_BUILD_PATH%\src\qmapshack\*.qm translations
copy %QMSI_BUILD_PATH%\src\qmaptool\*.qm translations
copy ..\*.ico

rem section 2.4.1) Copy the documentation files
mkdir doc
cd doc
mkdir HTML
copy ..\..\..\src\qmapshack\doc\QMSHelp.* HTML
copy ..\..\..\src\qmaptool\doc\QMTHelp.* HTML
cd ..

rem section 2.5) 3rd party SW description and LICENSE
copy ..\3rdparty.txt
copy ..\..\LICENSE 1LICENSE.txt

rem section 2.6) qt.conf
copy ..\qt.conf

cd %QMSI_QMS_PATH%\QMapShack\msvc_64\Files
mkdir data
xcopy %QMSI_GIS_PATH%\bin\gdal-data data /s /i
copy %QMSI_GIS_PATH%\bin\*.dll
mkdir gdalplugins
xcopy %QMSI_GIS_PATH%\bin\gdal\plugins gdalplugins /s /i
del .\gdalplugins\gdal_GEOR.dll .\gdalplugins\ogr_OCI.dll
copy %QMSI_GIS_PATH%\bin\curl-ca-bundle.crt
copy %QMSI_GIS_PATH%\bin\gdal\apps\*.exe
copy %QMSI_GIS_PATH%\bin\proj9\apps\*.exe
mkdir share\proj
xcopy %QMSI_GIS_PATH%\bin\proj9\share share\proj /s /i

Prev (GDAL support for additional map formats) | Home | Manual | Index | Top | (Ubuntu-14.04) Next