QGIS編譯 3.14.6+win10+vs2015概述整體步驟是根據(jù)官方的安裝指南來完成,因為安裝指南比較簡略,并且還存在一些瑕疵,導(dǎo)致完全根據(jù)官方指南自己編譯會出不少問題。官網(wǎng)詳情:https://github.com/qgis/QGIS/blob/release-3_14/INSTALL.md 安裝過程我會粘貼進(jìn)部分官方的編譯指南(英語部分) 下載VS2015并安裝4.1.1. Visual Studio 2015 Community Edition 安裝時選擇自定義安裝,需要勾選一下兩項 需要確認(rèn)10.0.14393已經(jīng)裝好,不然后面的腳本會出錯 下載其他工具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等等一些列的包 復(fù)制ninjaninja: copy ninja.exe to C:\OSGeo4W64\bin 下載QGIS源碼包下面是下載QGIS的源碼包,不需要通過git來下載,git下載的是沒有壓縮過的,數(shù)據(jù)大概有2G,也比較慢,直接到github上面下載你想要的版本,目前最新的是3.14.6 設(shè)置環(huán)境變量下面就開始進(jìn)入到批操作的環(huán)節(jié)了 @echo off call C:\OSGeo4W64\QGIS\ms-windows\osgeo4w\msvc-env.bat x86_64 @cmd 將以上內(nèi)容復(fù)制進(jìn)去,保存為 OSGeo4W-dev.bat 雙擊運(yùn)行,這個是用于設(shè)置環(huán)境變量之類的,正常運(yùn)行時不會報錯的,有報錯又要仔細(xì)看看報錯內(nèi)容。 通過命令行使用CMake 生成msvc的解決方案文件下面開始通過命令行來cmake了 cd C:\OSGeo4W64\QGIS\ms-windows\osgeo4w configonly.bat 進(jìn)入C:\OSGeo4W64\QGIS\ms-windows\osgeo4w目錄,運(yùn)行configonly.bat 應(yīng)該就不會出現(xiàn)什么問題了。 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. 在命令行中首先運(yùn)行之前的C:\OSGeo4W64\OSGeo4W-dev.bat ,然后接著輸入 call gdal-dev-env.bat,這也是在設(shè)置環(huán)境變量。 然后在當(dāng)前命令行中輸入 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這個路徑下面。 運(yùn)行QGIS如果想要在msvc外面運(yùn)行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,即可打開。 調(diào)試QGIS在msvc下調(diào)試時,先把qgis設(shè)置為活動項目(右鍵這個項目,選擇設(shè)置為活動項目),然后點(diǎn)擊 local windows debugger,或者菜單欄上Debug->start without Debugging。就能調(diào)試運(yùn)行了。 bat文件的內(nèi)容如上,然后雙擊這個bat文件來打開vs,再打開qgis項目應(yīng)該就沒問題了 |
|