QGIS编译 3.14.6+win10+vs2015概述整体步骤是根据官方的安装指南来完成,因为安装指南比较简略,并且还存在一些瑕疵,导致完全根据官方指南自己编译会出不少问题。官网详情:https://github.com/qgis/QGIS/blob/release-3_14/INSTALL.md 安装过程我会粘贴进部分官方的编译指南(英语部分) 下载VS2015并安装4.1.1. Visual Studio 2015 Community Edition 安装时选择自定义安装,需要勾选一下两项 需要确认10.0.14393已经装好,不然后面的脚本会出错 下载其他工具4.1.2. Other tools and dependencies Download and install following packages: CMake 用于安装 flex和bison的 cygwin OSGeo4W ninja 通过cygwin安装flex和bison通过cygwin安装以下两个包,git完全可以不安装。 ·bison 通过OSGeo4W 安装依赖包下面是通过OSGeo4W 来安装qgis的依赖包括qt,python等等一些列的包 复制ninjaninja: copy ninja.exe to C:\OSGeo4W64\bin 下载QGIS源码包下面是下载QGIS的源码包,不需要通过git来下载,git下载的是没有压缩过的,数据大概有2G,也比较慢,直接到github上面下载你想要的版本,目前最新的是3.14.6 设置环境变量下面就开始进入到批操作的环节了 @echo off call C:\OSGeo4W64\QGIS\ms-windows\osgeo4w\msvc-env.bat x86_64 @cmd 将以上内容复制进去,保存为 OSGeo4W-dev.bat 双击运行,这个是用于设置环境变量之类的,正常运行时不会报错的,有报错又要仔细看看报错内容。 通过命令行使用CMake 生成msvc的解决方案文件下面开始通过命令行来cmake了 cd C:\OSGeo4W64\QGIS\ms-windows\osgeo4w configonly.bat 进入C:\OSGeo4W64\QGIS\ms-windows\osgeo4w目录,运行configonly.bat 应该就不会出现什么问题了。 C:\OSGeo4W64\qgis\ms-windows\osgeo4w> configonly.bat BEGIN: 2020/09/26 周六 21:13:00.60 CMAKE: 2020/09/26 周六 21:13:01.08 -- The C compiler identification is MSVC 19.0.24215.1 -- The CXX compiler identification is MSVC 19.0.24215.1 -- Check for working C compiler: C:/Program Files (x86)/Microsoft Visual Studio 14.0/VC/bin/x86_amd64/cl.exe -- Check for working C compiler: C:/Program Files (x86)/Microsoft Visual Studio 14.0/VC/bin/x86_amd64/cl.exe -- works -- Detecting C compiler ABI info -- Detecting C compiler ABI info - done-- Detecting C compile features -- Detecting C compile features - done-- Check for working CXX compiler: C:/Program Files (x86)/Microsoft Visual Studio 14.0/VC/bin/x86_amd64/cl.exe -- Check for working CXX compiler: C:/Program Files (x86)/Microsoft Visual Studio 14.0/VC/bin/x86_amd64/cl.exe -- works -- Detecting CXX compiler ABI info -- Detecting CXX compiler ABI info - done-- Detecting CXX compile features -- Detecting CXX compile features - done-- QGIS version: 3.14.16 Pi (31416)-- Looking for CL_VERSION_2_2 -- Looking for CL_VERSION_2_2 - found -- Found OpenCL: C:/OSGeo4W64/lib/opencl.lib (found version "2.2")-- Found OpenCL C++ headers: C:/OSGeo4W64/include -- Found GRASS 7: C:/OSGEO4~2/apps/grass/grass78 (7.8.3, off_t size = 8)-- Found Proj: C:/OSGeo4W64/apps/proj-dev/lib/proj.lib version 7 (7.2.0)-- Found GEOS: C:/OSGeo4W64/lib/geos_c.lib (3.8.1)-- Found GDAL: C:/OSGeo4W64/apps/gdal-dev/lib/gdal_i.lib (3.2.0dev)-- Found Expat: C:/OSGeo4W64/lib/expat.lib -- Found Spatialindex: C:/OSGeo4W64/lib/spatialindex-64.lib -- Found Qwt: C:/OSGeo4W64/apps/Qt5/lib/qwt.lib (6.1.3)-- Found LibZip: C:/OSGeo4W64/lib/zip.lib -- Found libzip: C:/OSGeo4W64/lib/zip.lib -- Found Sqlite3: C:/OSGeo4W64/lib/sqlite3_i.lib -- Found Protobuf: C:/OSGeo4W64/lib/libprotobuf.lib (found version "3.11.4")-- Found Protobuf: C:/OSGeo4W64/lib/libprotobuf.lib -- Found ZLIB: C:/OSGeo4W64/lib/zlib.lib (found version "1.2.8")-- Found zlib: C:/OSGeo4W64/lib/zlib.lib -- Found PostgreSQL: C:/OSGeo4W64/lib/libpq.lib -- Found SpatiaLite: C:/OSGeo4W64/lib/spatialite_i.lib -- Qt WebKit support enabled -- Found Qt version: 5.11.2 -- Found QScintilla2: C:/OSGeo4W64/apps/Qt5/lib/qscintilla2.lib (2.10.8)-- Found QtKeychain: C:/OSGeo4W64/apps/Qt5/lib/qt5keychain.lib -- Found QCA: C:\OSGEO4~2\apps\Qt5\lib\qca-qt5.lib (2.1.3)-- Pedantic compiler settings enabled -- Debug output enabled -- Found GSL: C:/OSGeo4W64/lib/gsl.lib;C:/OSGeo4W64/lib/cblas.lib -- Found PythonInterp: C:/OSGeo4W64/bin/python3.exe (found suitable version "3.7", minimum required is "3")-- Found Python executable: C:/OSGeo4W64/bin/python3.exe -- Found Python version: 3.7.0 -- Found Python library: C:/OSGeo4W64/apps/Python37/libs/python37.lib -- Found Python site-packages: C:/OSGEO4~2/apps/Python37/Lib/site-packages -- Found PyQt5 version: 5.11.3 -- Found SIP version: 4.19.14 -- Found QScintilla2 PyQt module: 2.10.8 -- Performing Test COMPILER_HAS_DEPRECATED_ATTR -- Performing Test COMPILER_HAS_DEPRECATED_ATTR - Failed -- Performing Test COMPILER_HAS_DEPRECATED -- Performing Test COMPILER_HAS_DEPRECATED - Success -- Found exiv2: C:/OSGeo4W64/lib/exiv2.lib -- Found HDF5: hdf5::hdf5-shared (found version "1.10.4")-- Could NOT find PkgConfig (missing: PKG_CONFIG_EXECUTABLE)-- Found NetCDF: C:/OSGeo4W64/lib/netcdf.lib -- Found LibXml2: C:/OSGeo4W64/lib/libxml2.lib (found version "2.9.1")-- Found OCI: C:/OSGeo4W64/lib/oci.lib -- Found FCGI: C:/OSGeo4W64/lib/libfcgi.lib -- Using PROJ >= 6 srs database. -- Ctest Binary Directory set to: C:/OSGeo4W64/qgis/ms-windows/osgeo4w/build-qgis-test-x86_64/output/bin -- Configuring done-- Generating doneCMake Warning: Manually-specified variables were not used by the project: CMAKE_INSTALL_SYSTEM_RUNTIME_LIBS_NO_WARNINGS QT_HEADERS_DIR -- Build files have been written to: C:/OSGeo4W64/qgis/ms-windows/osgeo4w/build-qgis-test-x86_64 Exiting after configuring build directory: C:\OSGeo4W64\qgis\ms-windows\osgeo4w\build-qgis-test-x86_64 FINISHED: 2020/09/26 周六 21:16:20.64 使用msvc来编译QGIS下面开始使用msvc来编译
to add the release gdal and proj libraries to your PATH. On the command prompt run
to open MSVC. From MSVC, open the solution file C:\OSGeo4W64\QGIS\ms-windows\osgeo4w\build-qgis-test-x86_64\qgis.sln. Try to build the solution (go grab a cup of tea, it may take a while). If it fails, run it again and again until there are (hopefully) no errors. 在命令行中首先运行之前的C:\OSGeo4W64\OSGeo4W-dev.bat ,然后接着输入 call gdal-dev-env.bat,这也是在设置环境变量。 然后在当前命令行中输入 devenv,打开msvc,然后从以下目录打开工程C:\OSGeo4W64\QGIS\ms-windows\osgeo4w\build-qgis-test-x86_64\qgis.sln 因为项目比较大,所以载入需要很长一段时间,里面大概有501个项目。 编译步骤比较重要, 编译qgis_core 大约一个半小时,qgis_gui 大概一个多小时 编译完成后,所有生成的文件会在C:\OSGeo4W64\qgis\ms-windows\osgeo4w\build-qgis-test-x86_64\output\bin\RelWithDebInfo这个路径下面。 运行QGIS如果想要在msvc外面运行QGIS,按照如下做法 @echo off call C:\OSGeo4W64\QGIS\ms-windows\osgeo4w\msvc-env.bat x86_64 call gdal-dev-env.bat @cmd start qgis.exe 双击 qgis_run.bat,在跳出来的命令行后再输入qgis.exe,即可打开。 调试QGIS在msvc下调试时,先把qgis设置为活动项目(右键这个项目,选择设置为活动项目),然后点击 local windows debugger,或者菜单栏上Debug->start without Debugging。就能调试运行了。 bat文件的内容如上,然后双击这个bat文件来打开vs,再打开qgis项目应该就没问题了 |
|