QGIS的編譯 (Windows)


一、資源

https://github.com/qgis/QGIS

https://github.com/qgis/QGIS/blob/master/INSTALL.md

 

二、編譯需求

Following a summary of the required dependencies for building:

Required build tools:

 

* CMake >= 3.10.0

* Flex >= 2.5.6

* Bison >= 2.4

* Python >= 3.7

 

Required build dependencies:

 

* Qt >= 5.12.0

* Proj >= 4.9.3

* GEOS >= 3.4

* Sqlite3 >= 3.0.0

* SpatiaLite >= 4.2.0

* libspatialindex

* GDAL/OGR >= 2.1

* Qwt >= 5.0 & (< 6.1 with internal QwtPolar)

* expat >= 1.95

* QScintilla2

* QCA

* qtkeychain (>= 0.5)

* libzip

 

Optional dependencies:

 

* for GRASS providers and plugin - GRASS >= 7.0.0.

* for georeferencer - GSL >= 1.8

* for PostGIS support - PostgreSQL >= 8.0.x

* for gps plugin - gpsbabel

* for mapserver export and PyQGIS - Python >= 3.6

* for python support - SIP >= 4.12, PyQt >= 5.3 must match Qt version, Qscintilla2

* for qgis mapserver - FastCGI

* for oracle provider - Oracle OCI library

Indirect dependencies:

Some proprietary formats (e.g., ECW and MrSid) supported by GDAL require proprietary third party libraries. QGIS doesn't need any of those itself to build, but will only support those formats if GDAL is built accordingly. Refer to http://gdal.org/formats_list.html ff. for instructions how to include those formats in GDAL.

 

三、Building on Windows using vs

3.1 Other tools and dependencies

Download and install following packages:

Tool

Website

CMake

https://cmake.org/download/

GNU flex, GNU bison and GIT

在 windows 系統上提供的類 unix 環境,用於下載所需要的包。

http://cygwin.com/setup-x86.exe (32bit) or 

http://cygwin.com/setup-x86_64.exe (64bit)

OSGeo4W

用於 windows 系統里一系列的開源 gis 的發布。

http://download.osgeo.org/osgeo4w/osgeo4w-setup-x86_64.exe  (推薦)

https://qgis.org/en/site/forusers/download.html

 

OSGeo4W介紹

ninja

https://github.com/ninja-build/ninja/releases/download/v1.7.2/ninja-win.zip

For the QGIS build you need to install following packages from cygwin:

  • bison
  • flex
  • git

and from OSGeo4W (select Advanced Installation):

  • qgis-dev-deps

This will also select packages the above packages depend on.

If you install other packages, this might cause issues. Particularly, make sure not to install the msinttypes package. It installs a stdint.h file in OSGeo4W[64]\include, that conflicts with Visual Studio own stdint.h, which for example breaks the build of the virtual layer provider.

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.

ninja: copy ninja.exe to d:\OSGeo4W64\bin\

 

 

補充說明:

1. cygwin的安裝

一步步安裝,直至選擇包的界面,分別搜索需以上的包,若未安裝,會顯示 skip,點擊切換版本即可。下圖為已安裝,顯示為 keep。

 

搜索了:flex,  bison, ninja,。

 

2. OSGeo4W安裝 (例如,若自己電腦上有QGIS 3.12安裝版本,可省去這部分)

選擇 Advanced Install,否則安裝路徑假設默認為 C:\OSGeo4W64。

之后一步步安裝,直至選擇包界面。
后面的步驟省去,和cygwin類似。

 

到選擇包界面時,輸入 qgis-dev-deps,同樣,若未安裝,會顯示為 skip,點擊切換版本即可。

 

備注:

qgis-dev-deps要安裝的內容如下。

avce00    (2.0.0-1)

The AVCE00 commandline utilities for Arc/Info E00 conversion

Required by: grass

 

boost-libs    (1.56.0-2)

The Boost library (runtime libraries).

Required by: libkml

 

cairo    (1.12.14-1)

Cairo library

Required by: grass

 

curl    (7.67.0-1)

The CURL HTTP/FTP library and commandline utility.

Required by: gdal-dev, proj-dev, netcdf, gdal, gdal111dll

 

curl-ca-bundle    (20191119-1)

CURL CA certificates

Required by: curl

 

exiv2    (0.26-1)

Image metadata library

Required by: exiv2-devel

 

exiv2-devel    (0.26-1)

Image metadata library (development)

Required by: qgis-dev-deps

 

expat    (2.1.0-1)

The Expat XML Parser library

Required by: qgis-dev-deps, gdal-dev, ogdi, gpsbabel, gdal, exiv2, gdal111dll, libkml

 

fcgi    (2.4.1-2)

FastCGI Library

Required by: qgis-dev-deps

 

fftw    (3.3.3-1)

Fast Fourier transformation library (Development)

Required by: grass

 

freexl    (1.0.2-1)

The FreeXL library for accessing Excel (.xls) spreadsheet.

Required by: gdal-dev, spatialite, gdal, gdal111dll

 

gdal    (3.0.4-2)

The GDAL/OGR library and commandline tools

Required by: grass, gpsbabel, python3-gdal

 

gdal-dev    (3.1.0-273)

The GDAL/OGR library and commandline tools (nightly master)

Required by: qgis-dev-deps

 

gdal111dll    (1.11.3-1)

The GDAL/OGR 1.11 DLL (backward compability package)

Required by: liblas

 

geos    (3.8.1-1)

The GEOS geometry library

Required by: gdal-dev, spatialite, gdal, liblwgeom, gdal111dll

 

gpsbabel    (1.4.4-2)

GPS file conversion plus transfer to/from GPS units

Required by: grass

 

grass    (7.8.2-2)

GRASS GIS

Required by: qgis-dev-deps

 

gs    (9.07-1)

Ghostscript

Required by: grass

 

gsl-devel    (1.15-1)

GNU Scientific Library (GSL; Development)

Required by: qgis-dev-deps

 

gsl-libs    (1.15-1)

GNU Scientific Library (GSL)

Required by: gsl-devel

 

hdf4    (4.2.14-1)

The HDF4 library for reading and writing HDF4 format

Required by: gdal-dev, gdal, gdal111dll

 

hdf5    (1.10.4-1)

The HDF5 library for reading and writing HDF5 format

Required by: netcdf, gdal111dll

 

iconv    (1.14-1)

Codepage translation Library

Required by: qgis-dev-deps, grass, spatialite, freexl, cairo, gdal111dll

 

iconv-vc14    (1.15-1)

Codepage translation Library

Required by: gdal-dev, gdal

 

icu-libs    (56.1-3)

ICU (library)

Required by: qtwebkit-qt5-libs

 

laszip2    (2.2.0-3)

The LASzip compression library (version 2)

Required by: liblas

 

libgeotiff    (1.4.2-1)

The Libgeotiff library, commandline tools and supporting tables.

Required by: liblas, gdal111dll

 

libjpeg    (6b-4)

A library for manipulating JPEG image format files

Required by: gdal-dev, libtiff, gdal111dll

 

libjpeg12    (6b-4)

A library for manipulating 12bit JPEG image format files

Required by: libtiff

 

libkml    (1.3.0-1)

LibKML

Required by: gdal

 

liblas    (1.8.0-1)

The libLAS commandline utilities

Required by: grass

 

liblwgeom    (3.0.0-2)

liblwgeom

Required by: spatialite

 

libmysql    (6.1.9-1)

MySQL Client Library.

Required by: gdal-dev, gdal, gdal111dll

 

libpng    (1.6.3-1)

the official PNG reference library

Required by: gdal-dev, grass, gdal

 

libpng-vc14    (1.6.29-1)

the official PNG reference library

Required by: openjpeg

 

libpq    (11.5-1)

The libpq library for accessing PostgreSQL + psql commandline client

Required by: gdal-dev, gdal, gdal111dll

 

libspatialindex    (1.9.0-1)

The libspatialindex library

Required by: qgis-dev-deps

 

libtiff    (4.0.8-1)

A library for manipulating TIFF format image files (runtime)

Required by: grass, proj-dev, openjpeg, liblas, libgeotiff, gdal111dll

 

libxml2    (2.9.1-1)

An XML read/write library

Required by: spatialite, cairo

 

libzip-devel    (1.2.0-2)

libzip (development)

Required by: qgis-dev-deps

 

libzip-libs    (1.2.0-2)

libzip (runtime library)

Required by: libzip-devel

 

msvc2015    (1.0.0-1)

msvc2015

Required by: spatialite, icu-libs

 

msvcrt    (1.0.3-1)

Microsoft Visual C/C++ Runtimes

Required by: grass, oci-devel, shell, openjpeg, msvcrt2015, oci, opencl, setup, libkml

 

msvcrt2008    (1.0.0-1)

Microsoft Visual C/C++ 2008 Runtimes

Required by: msvcrt

 

msvcrt2010    (1.0.0-2)

Microsoft Visual C/C++ 2010 Runtimes

Required by: msvcrt, xerces-c-vc10

 

msvcrt2012    (1.0.0-2)

Microsoft Visual C/C++ 2012 Runtimes.

Required by: boost-libs

 

msvcrt2013    (1.0.0-2)

Microsoft Visual C/C++ 2013 Runtimes

Required by: grass, liblas

 

msvcrt2015    (1.0-2)

Microsoft Visual C/C++ 2015 Runtimes

Required by: grass, libspatialindex, proj-dev, curl, geos, libmysql, sqlite3, libpq, xerces-c, hdf4, ogdi, iconv-vc14, zstd, libtiff, gdal, proj, libzip-libs, python3-core, qt5-libs, liblwgeom, msvc2015, exiv2, protobuf, openssl, hdf5, szip, laszip2, xz

 

netcdf    (4.7.3-1)

The NetCDF library and commands for reading and writing NetCDF format

Required by: gdal-dev, gdal, gdal111dll

 

oci    (12.1.0.1.0-1)

Oracle Instant Client

Required by: oci-devel

 

oci-devel    (12.1.0.1.0-1)

Oracle Instant Client (Development)

Required by: qgis-dev-deps

 

ogdi    (4.1.0-1)

OGDI data access library (mainly for VPF reading)

Required by: gdal-dev, gdal, gdal111dll

 

opencl    (2.0.10-5)

KhronosGroup OpenCL runtime

Required by: opencl-devel

 

opencl-devel    (2.0.10-4)

KhronosGroup OpenCL development files

Required by: qgis-dev-deps

 

openjpeg    (2.3.0-1)

OpenJPEG

Required by: gdal-dev, gdal, gdal111dll

 

openssl    (1.1.1d-2)

OpenSSL Cryptography (Runtime)

Required by: curl, libpq, python3-core, qt5-libs

 

openssl10    (1.0.2j-1)

OpenSSL 1.0 Cryptography (Old Runtime)

Required by: libzip-libs, openssl

 

pdcurses    (3.4-2)

PDCurses (MinGW built)

Required by: grass

 

proj    (6.3.1-1)

The PROJ library and commands for coordinate system transformations.

Required by: grass, spatialite, liblas, gdal, liblwgeom, gdal111dll

 

proj-datumgrid    (1.8-1)

Assorted PROJ datum grid shift files

Required by: proj-dev, liblas, proj

 

proj-dev    (7.1.0-37)

The PROJ library and commands for coordinate system transformations (nightly master).

Required by: gdal-dev

 

proj-dev-data    (1.1-4)

The PROJ data (nightly master).

Required by: proj-dev

 

proj-hpgn    (1.0-1)

PROJ.4 HPGN (HARN) grid shift files

Required by: proj-dev, liblas, proj

 

protobuf    (3.11.4-2)

Protocol Buffers - Google's data interchange format

Required by: protobuf-devel

 

protobuf-devel    (3.11.4-2)

Protocol Buffers - Google's data interchange format (development)

Required by: qgis-dev-deps

 

pyqt5    (5.11.3-2)

Python bindings for Qt5.

Required by: qgis-dev-deps, python3-qscintilla

 

python3-core    (3.7.0-4)

Python3 core interpreter and runtime

Required by: pyqt5, python3-devel, python3-qscintilla, python3-nose2, python3-future, python3-pyyaml, python3-mock, python3-six, sip-qt5, python3-gdal, python3-matplotlib, python3-wx, python3-numpy, python3-pillow, python3-pip, python3-ply, python3-pyopengl, python3-pywin32, python3-coverage, python3-pbr, python3-pyparsing, python3-cycler, python3-kiwisolver, python3-python-dateutil, python3-psycopg2-binary, python3-setuptools

 

python3-coverage    (4.5.1-1)

Code coverage measurement for Python

Required by: python3-nose2

 

python3-cycler    (0.10.0-2)

Composable style cycles

Required by: python3-matplotlib

 

python3-devel    (3.7.0-1)

Python3 library and header files

Required by: qgis-dev-deps

 

python3-future    (0.16.0-2)

Clean single-source support for Python 3 and 2

Required by: qgis-dev-deps

 

python3-gdal    (3.0.4-2)

The GDAL/OGR Python3 Bindings and Scripts

Required by: grass

 

python3-kiwisolver    (1.1.0-1)

A fast implementation of the Cassowary constraint solver

Required by: python3-matplotlib

 

python3-matplotlib    (3.1.3-1)

Python plotting package

Required by: grass

 

python3-mock    (2.0.0-2)

Rolling backport of unittest.mock for all Pythons

Required by: qgis-dev-deps

 

python3-nose2    (0.8.0-1)

nose2 is the next generation of nicer testing for Python

Required by: qgis-dev-deps

 

python3-numpy    (1.18.1-1)

NumPy is the fundamental package for array computing with Python.

Required by: grass, python3-gdal, python3-matplotlib

 

python3-pbr    (4.3.0-1)

Python Build Reasonableness

Required by: python3-mock

 

python3-pillow    (5.3.0-1)

Python Imaging Library (Fork)

Required by: grass

 

python3-pip    (20.0.2-1)

The PyPA recommended tool for installing Python packages.

Required by: grass

 

python3-ply    (3.11-2)

Python Lex & Yacc

Required by: grass

 

python3-psycopg2    (2.8.4-1)

psycopg2 - Python-PostgreSQL Database Adapter (transitional)

Required by: grass

 

 

python3-psycopg2-binary    (2.8.4-1)

psycopg2 - Python-PostgreSQL Database Adapter

Required by: python3-psycopg2

 

python3-pyopengl    (3.1.0-1)

Standard OpenGL bindings for Python

Required by: grass

 

python3-pyparsing    (2.4.6-1)

Python parsing module

Required by: python3-matplotlib

 

python3-python-dateutil    (2.8.1-1)

Extensions to the standard Python datetime module

Required by: python3-matplotlib

 

python3-pywin32    (224-1)

Python for Window Extensions

Required by: grass

 

python3-pyyaml    (5.3-1)

YAML parser and emitter for Python

Required by: qgis-dev-deps

 

python3-qscintilla    (2.10.8-1)

Python3 bindings for Qt5 QScintilla

Required by: qgis-dev-deps

 

python3-setuptools    (45.2.0-1)

Easily download, build, install, upgrade, and uninstall Python packages

Required by: python3-kiwisolver

 

python3-six    (1.14.0-1)

Python 2 and 3 compatibility utilities

Required by: qgis-dev-deps, grass, python3-nose2, python3-mock, python3-wx, python3-cycler, python3-python-dateutil

 

python3-wx    (4.0.7-1)

wxPython - Python3 bindings for wxWidgets

Required by: grass

 

qca-qt5-devel    (2.1.3-1)

Qt5 Cryptographic Architecture headers and libraries (Development)

Required by: qgis-dev-deps

 

qca-qt5-libs    (2.1.3-1)

Qt5 Cryptographic Architecture runtime libraries

Required by: qgis-dev-deps

 

qscintilla-qt5    (2.10.8-1)

Qt5 source code editing component.

Required by: qgis-dev-deps, python3-qscintilla

 

qt5-devel    (5.11.2-1)

Qt5 headers and libraries (Development)

Required by: qgis-dev-deps, qca-qt5-devel, qtkeychain-qt5-devel

 

qt5-libs    (5.11.2-1)

Qt5 runtime libraries

Required by: pyqt5, qca-qt5-devel, qca-qt5-libs, qscintilla-qt5, qt5-devel, qtkeychain-qt5-devel, qtwebkit-qt5-libs, qtwebengine-qt5-libs, qwt-libs-qt5, qtkeychain-qt5-libs

 

qt5-libs-debug    (5.11.2-1)

Qt5 runtime libraries (debug version)

Required by: qgis-dev-deps

 

qtkeychain-qt5-devel    (0.9-1)

Platform-independent Qt API for storing passwords securely. (Development)

Required by: qgis-dev-deps

 

qtkeychain-qt5-libs    (0.9-1)

Platform-independent Qt API for storing passwords securely.

Required by: qtkeychain-qt5-devel

 

qtwebengine-qt5-libs    (5.10.1-1)

WebEngine for Qt5

Required by: pyqt5

 

qtwebkit-qt5-devel    (5.212-1)

WebKit for Qt5 (development)

Required by: qgis-dev-deps

 

qtwebkit-qt5-libs    (5.212-1)

WebKit for Qt5

Required by: pyqt5, qtwebkit-qt5-devel, qtwebkit-qt5-libs-debug

 

qtwebkit-qt5-libs-debug    (5.9.1-1)

WekKit for Qt5 (debug libraries)

Required by: qgis-dev-deps

 

qwt-devel-qt5    (6.1.3-5)

Qt5 widgets library for technical applications (Development)

Required by: qgis-dev-deps

 

qwt-libs-qt5    (6.1.3-5)

Qt5 widgets library for technical applications (runtime)

Required by: qwt-devel-qt5

 

rbatch    (149-4)

Windows batchfiles for use with R

Required by: grass

 

setup    (1.0.7-16)

OSGeo4W Installer/Updater

Required by: shell

 

shell    (1.0.2-4)

OSGeo4W Command Shell

Required by: expat, fcgi, gdal-dev, gsl-devel, iconv, python3-qscintilla, qca-qt5-devel, qscintilla-qt5, qt5-libs-debug, qwt-devel-qt5, qtkeychain-qt5-devel, libpng, libjpeg, liblas, avce00, gpsbabel, pdcurses, zlib, fftw, cairo, gsl-libs, qwt-libs-qt5, libxml2, setup, libpng-vc14, libgeotiff, gdal111dll, laszip2, libjpeg12

 

sip-qt5    (4.19.14-1)

Python3/C++ bindings generator (Development)

Required by: qgis-dev-deps, pyqt5

 

spatialite    (4.3.0a-6)

The SpatiaLite library for adding spatial capabilities to SQLite3 DBMS.

Required by: qgis-dev-deps, gdal-dev, gdal, gdal111dll

 

sqlite3    (3.29.0-1)

The SQLite3 library for accessing SQLite3 database files.

Required by: gdal-dev, spatialite, proj-dev, gdal, python3-core, qt5-libs, gdal111dll

 

szip    (2.1.1-1)

SZIP compression library

Required by: hdf4, hdf5

 

xerces-c    (3.2.0-1)

The Xerces-C 3 library for parsing XML files (runtime)

Required by: gdal-dev, gdal

 

xerces-c-vc10    (3.1.1-1)

The Xerces-C 3 library for parsing XML files

Required by: gdal111dll

 

xz    (5.2.3-1)

XZ-format compression library

Required by: libtiff, gdal

 

zlib    (1.2.8-1)

The zlib compression and decompression library (runtime)

Required by: grass, qt5-libs-debug, ogdi, openjpeg, gpsbabel, libtiff, cairo, qt5-libs, exiv2, protobuf, libkml

 

zstd    (1.3.2-1)

Zstandard Long Range Match Finder (runtime)

Required by: gdal-dev, grass, gdal, zstd-bin

 

zstd-bin    (1.3.2-1)

Zstandard Long Range Match Finder (binary)

Required by: grass

 

上面這一步是輸入qgis-dev-deps ,其他的都不要,如果以前安裝過QGIS最好要換一個安裝目錄,因為msinttypes中的頭文件可能與VS2015中的文件件沖突,官方原話是這樣的

接下來把git上下載的QGIS源碼(建議用移動網絡手機WiFi熱點下載,實測電信30kiB/s, 移動 4G通用流量 500kiB/s,5G套餐流量,使用4G手機,最快達到5.05 MiB/s)。

 

可以看出,在2020.4.27的時候,qgis的源碼已經達到了 1.64GB,下載時,一定要找一個網絡比較穩定的時候。否則直接git clone將非常耗時。我之所以使用git clone, 是為了日后直接關聯到 github遠程倉庫,同步遠程倉庫的

將源碼文件夾解壓出來,我是把文件都放在“OSGeo4W”安裝的父目錄下,當然這個是可以自定義的。例如,放到一個編譯qgis源碼的父目錄下 E:\Projs\algs\qgis\。

把ninj解壓出來的EXE文件放入XXX\OSGeo4W64\bin目錄中。

 

3.2 Setting up the Visual Studio project with Cmake

環境設置

以下保存為批處理文件 XXX\qgis-dev.bat,其中具體的路徑,替換成自己機子環境對應的路徑,

其中的路徑包括 vs 、window sdk、OSGeo、cygwin64等。

@echo off
set VS140COMNTOOLS = D:\Go\Program\Microsoft Visual Studio 14.0
call "D:\Go\Program\Microsoft Visual Studio 14.0\VC\vcvarsall.bat" x64
set INCLUDE=%INCLUDE%;C:\Program Files (x86)\Microsoft SDKs\Windows\v7.1A\Include
set LIB=%LIB%;C:\Program Files (x86)\Microsoft SDKs\Windows\v7.1A\Lib
set OSGEO4W_ROOT=C:\OSGeo4W64
call "%OSGEO4W_ROOT%\bin\o4w_env.bat"
call "%OSGEO4W_ROOT%\bin\py3_env.bat"
call "%OSGEO4W_ROOT%\bin\qt5_env.bat"
set O4W_ROOT=%OSGEO4W_ROOT:\=/%
set LIB_DIR=%O4W_ROOT%
path %path%;D:\Go\Program\Microsoft Visual Studio 14.0\VC\bin
path %PATH%;D:\Go\Program\CMake\bin;E:\ProgramFiles\cygwin64\bin
@set GRASS_PREFIX=C:\OSGeo4W64\apps/grass/grass-7.6.0
@set INCLUDE=%INCLUDE%;%OSGEO4W_ROOT%\include
@set LIB=%LIB%;%OSGEO4W_ROOT%\lib;%OSGEO4W_ROOT%\lib
set LIB=%LIB%;%OSGEO4W_ROOT%\apps\Qt5\lib;%OSGEO4W_ROOT%\lib
set INCLUDE=%INCLUDE%;%OSGEO4W_ROOT%\apps\Qt5\include;%OSGEO4W_ROOT%\include
@cmd

備注:

1)如果是vs2017, 上面兩行藍色的內容,並不好填寫,可以省去。在cmake的時候,可以自動彈出窗口,選擇設置。

2)以上表格中的內容的路徑,以D:/Pros/Office/QGIS_Dev/OSGeo4W/apps/Python37/形式填寫,否則cmake得到的vs工程里,安裝將會遇到"/p"的問題。

 

New my file

@echo off
call "C:\Program\Dev\Microsoft Visual Studio\2017\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64
set INCLUDE=%INCLUDE%;C:\Windows Kits\10\Lib\Include
set LIB=%LIB%;C:\Windows Kits\10\Lib
set OSGEO4W_ROOT=D:\Pros\Office\QGIS_Dev\OSGeo4W
call "%OSGEO4W_ROOT%\bin\o4w_env.bat"
call "%OSGEO4W_ROOT%\bin\py3_env.bat"
call "%OSGEO4W_ROOT%\bin\qt5_env.bat"
set O4W_ROOT=%OSGEO4W_ROOT:\=/%
set LIB_DIR=%O4W_ROOT%
path %PATH%;D:\Pros\IDE\IDE Tools\cmake-3.17.1-win64-x64\bin;D:\Pros\IDE\IDE Tools\cygwin64\bin
@set GRASS_PREFIX=D:\Pros\Office\QGIS_Dev\OSGeo4W\apps\grass\grass78
@set INCLUDE=%INCLUDE%;%OSGEO4W_ROOT%\include
@set LIB=%LIB%;%OSGEO4W_ROOT%\lib;%OSGEO4W_ROOT%\lib
set LIB=%LIB%;%OSGEO4W_ROOT%\apps\Qt5\lib;%OSGEO4W_ROOT%\lib
set INCLUDE=%INCLUDE%;%OSGEO4W_ROOT%\apps\Qt5\include;%OSGEO4W_ROOT%\include
@cmd

 

在D:\QGIS目錄下按住shift鍵不放,右擊鼠標選擇 “在此處打開power shell 窗口(s)” ,輸入下面命令進入cmake窗口。

 

 

cmake

雙擊以上保存的 qgis-dev.bat,輸入 cmake-gui,會彈出 cmake 的配置界面,寫好 qgis 源碼目錄及build 目錄。

build目錄,要放到下載的qgis的源碼根目錄下

點擊Configure后可能會出現一些錯誤,找到相應的路徑添加上去就行了,下面是我的路徑。

對上述cmake界面中的內容進行修改:

Enable test

Install please

Configure后,出現如下內容。

Selecting Windows SDK version 10.0.17763.0 to target Windows 10.0.18363.

QGIS version: 3.13.0 Master (31300)

Found OpenCL C++ headers: D:/Pros/Office/QGIS_Dev/OSGeo4W/include

Could not find GRASS 7

Found Proj: D:/Pros/Office/QGIS_Dev/OSGeo4W/lib/proj_i.lib version 6 (6.3.1)

Found GEOS: D:/Pros/Office/QGIS_Dev/OSGeo4W/lib/geos_c.lib (3.8.1)

Found GDAL: D:/Pros/Office/QGIS_Dev/OSGeo4W/lib/gdal_i.lib (3.0.4)

Found Expat: D:/Pros/Office/QGIS_Dev/OSGeo4W/lib/expat.lib

Found Spatialindex: D:/Pros/Office/QGIS_Dev/OSGeo4W/lib/spatialindex-64.lib

Found Qwt: D:/Pros/Office/QGIS_Dev/OSGeo4W/apps/Qt5/lib/qwt.lib (6.1.3)

Found libzip: D:/Pros/Office/QGIS_Dev/OSGeo4W/lib/zip.lib

Found Sqlite3: D:/Pros/Office/QGIS_Dev/OSGeo4W/lib/sqlite3_i.lib

Found Protobuf: D:/Pros/Office/QGIS_Dev/OSGeo4W/lib/libprotobuf.lib

Found zlib: D:/Pros/Office/QGIS_Dev/OSGeo4W/lib/zlib.lib

Found PostgreSQL: D:/Pros/Office/QGIS_Dev/OSGeo4W/lib/libpq.lib

Found SpatiaLite: D:/Pros/Office/QGIS_Dev/OSGeo4W/lib/spatialite_i.lib

Qt WebKit support enabled

Found Qt version: 5.11.2

Found QScintilla2: D:/Pros/Office/QGIS_Dev/OSGeo4W/apps/Qt5/lib/qscintilla2_qt5.lib (2.10.8)

Found QtKeychain: D:/Pros/Office/QGIS_Dev/OSGeo4W/apps/Qt5/lib/qt5keychain.lib

Found QCA: D:/Pros/Office/QGIS_Dev/OSGeo4W/apps/Qt5/lib/qca-qt5.lib (2.1.3)

Pedantic compiler settings enabled

Found Python executable: D:/Pros/Office/QGIS_Dev/OSGeo4W/bin/python3.exe

Found Python version: 3.7.0

Found Python library: D:/Pros/Office/QGIS_Dev/OSGeo4W/apps/Python37/libs/python37.lib

Found Python site-packages: D:/Pros/Office/QGIS_Dev/OSGeo4W/apps/Python37/Lib/site-packages

Found PyQt5 version: 5.11.3

Found SIP version: 4.19.14

Found QScintilla2 PyQt module: 2.10.8

txt2tags not found - disabled

Found exiv2: D:/Pros/Office/QGIS_Dev/OSGeo4W/lib/exiv2.lib

Could NOT find PkgConfig (missing: PKG_CONFIG_EXECUTABLE)

Found GSL: D:/Pros/Office/QGIS_Dev/OSGeo4W/lib/gsl.lib;D:/Pros/Office/QGIS_Dev/OSGeo4W/lib/cblas.lib

Using PROJ 6 srs database.

Ctest Binary Directory set to: E:/Projs/algs/qgis/qgis_source/build/output/bin

Configuring done

 

點擊Open Project后會打開VS2015,打開后出現的工程項目比較多,如果只要基本功能的話,可以只保留下面幾項,如果后期需要再加上。

 

右鍵qgis工程,選擇”設為啟動項目“,然后右鍵ALL_BULID“生成”。
在編譯過程中會出現一些錯誤與警告,可以參考這個百度文庫尾部。

打開后,項目非常多,無論是編譯、還是瀏覽,都非常慢。我們只需核心的幾個庫,其它的都移除。先把主程序運行起來,其它的插件若有需要再添加。

  • qgis:QGIS可執行程序
  • qgis_native:依賴項
  • libdxfrw:依賴項
  • qgis_app:
  • qgis_analysis:依賴項
  • qgis_core:依賴項,QGIS核心庫
  • qgis_gui:依賴項,QGIS核心庫
  • ui:QGIS所有的界面
  • gdalprovider:讀取柵格數據驅動
  • ogrprovider:讀取矢量數據驅動
  • version:版本

由於源代碼為 utf-8 編碼,本機 locale 為中文,編譯時可能出現 ”Newline in constant“ 的錯誤,需顯示告訴編譯器源碼為 utf-8 :

右鍵-Properties-- c/c++,Command Line,Addtional Options 里添加:

/source-charset:utf-8

編譯選項選擇“RelWithDebInfo”,進行編譯。由於源碼比較多,先編譯 core、native。總體耗時比較久,可能30分鍾以上。

 

生成“后運行就會出現下面結果。

備注:

為了在vs工程中,將工程分門別類的合並到文件夾內,可以如下設置:

cmake\CMakeHelper.cmake

cmake\CMakeHelper_end.cmake

# for folders in vs studio .sln projects.

# added by weng. 20.4.27

 

 

# Enable solution folders.

set_property(GLOBAL PROPERTY USE_FOLDERS ON)

set(CMAKE_TARGETS_ROOT_FOLDER "_build")

set_property(GLOBAL PROPERTY PREDEFINED_TARGETS_FOLDER ${CMAKE_TARGETS_ROOT_FOLDER})

set(QGIS_CORE_ROOT_FOLDER "_core")

set(QGIS_QGIS_LIBS_ROOT_FOLDER "_qgis")

set(QGIS_QGIS_TEST_ROOT_FOLDER "_qgis_test")

set(QGIS_ABOUT_ROOT_FOLDER "about")

set(QGIS_ZZZ_ROOT_FOLDER "zzz")

set(QGIS_SERVER_ROOT_FOLDER "server")

 

 

# Wrapper for test executables.

# macro(QGIS_ADD_TEST TARGET_NAME)

#    if(TESTS_ENABLED)

#        # ${ARGN} will store the list of source files passed to this function.

#        add_executable(${TARGET_NAME} ${ARGN})

#        set_target_properties(${TARGET_NAME} PROPERTIES FOLDER ${QGIS_QGIS_TEST_ROOT_FOLDER}/${FOLDER_NAME})

#        target_link_libraries(${TARGET_NAME} colmap ${Boost_UNIT_TEST_FRAMEWORK_LIBRARY})

#        add_test("${FOLDER_NAME}/${TARGET_NAME}" ${TARGET_NAME})

#        if(IS_MSVC)

#            install(TARGETS ${TARGET_NAME} DESTINATION bin/)

#        endif()

#    endif()

#endmacro(QGIS_ADD_TEST)

 

#

# weng for qgis test folders. 20.4.27

# set_target_properties(clean-staged-${plugin} PROPERTIES FOLDER ${QGIS_ZZZ_ROOT_FOLDER}/)

set_target_properties(libdxfrw PROPERTIES FOLDER ${QGIS_CORE_ROOT_FOLDER}/)

set_target_properties(mdalprovider PROPERTIES FOLDER ${QGIS_CORE_ROOT_FOLDER}/)

set_target_properties(owsprovider PROPERTIES FOLDER ${QGIS_CORE_ROOT_FOLDER}/)

set_target_properties(postgresprovider PROPERTIES FOLDER ${QGIS_CORE_ROOT_FOLDER}/)

set_target_properties(qgis PROPERTIES FOLDER ${QGIS_CORE_ROOT_FOLDER}/)

set_target_properties(qgis_3d PROPERTIES FOLDER ${QGIS_CORE_ROOT_FOLDER}/)

set_target_properties(qgis_analysis PROPERTIES FOLDER ${QGIS_CORE_ROOT_FOLDER}/)

set_target_properties(qgis_app PROPERTIES FOLDER ${QGIS_CORE_ROOT_FOLDER}/)

set_target_properties(qgis_core PROPERTIES FOLDER ${QGIS_CORE_ROOT_FOLDER}/)

set_target_properties(qgis_desktop PROPERTIES FOLDER ${QGIS_CORE_ROOT_FOLDER}/)

set_target_properties(qgis_gui PROPERTIES FOLDER ${QGIS_CORE_ROOT_FOLDER}/)

set_target_properties(qgis_native PROPERTIES FOLDER ${QGIS_CORE_ROOT_FOLDER}/)

set_target_properties(ui PROPERTIES FOLDER ${QGIS_CORE_ROOT_FOLDER}/)

set_target_properties(version PROPERTIES FOLDER ${QGIS_CORE_ROOT_FOLDER}/)

 

 

# uninstall

set_target_properties(uninstall PROPERTIES FOLDER ${CMAKE_TARGETS_ROOT_FOLDER}/)  # weng for qgis test folders. 20.4.27

 

 

 

# server

# not all server about projects.

# weng for qgis test folders. 20.4.29

set_target_properties(qgis_server_full PROPERTIES FOLDER ${QGIS_SERVER_ROOT_FOLDER}/)

set_target_properties(wms PROPERTIES FOLDER ${QGIS_SERVER_ROOT_FOLDER}/)

set_target_properties(wfs PROPERTIES FOLDER ${QGIS_SERVER_ROOT_FOLDER}/)

set_target_properties(wcs PROPERTIES FOLDER ${QGIS_SERVER_ROOT_FOLDER}/)

set_target_properties(wfs3 PROPERTIES FOLDER ${QGIS_SERVER_ROOT_FOLDER}/)

set_target_properties(wmts PROPERTIES FOLDER ${QGIS_SERVER_ROOT_FOLDER}/)

set_target_properties(qgis_server PROPERTIES FOLDER ${QGIS_SERVER_ROOT_FOLDER}/)

 

set_target_properties(qgis_mapserv.fcgi PROPERTIES FOLDER ${QGIS_SERVER_ROOT_FOLDER}/)

set_target_properties(qgis_serverquerystringparametertest PROPERTIES FOLDER ${QGIS_SERVER_ROOT_FOLDER}/)

 

然后設置1:

# Include helper macros and commands, and allow the included file to override

# the CMake policies in this file

include(${CMAKE_CURRENT_SOURCE_DIR}/cmake/CMakeHelper.cmake NO_POLICY_SCOPE)

 

 

# move vs projects to folder. weng 20.4.27

include(${CMAKE_CURRENT_SOURCE_DIR}/cmake/CMakeHelper_end.cmake NO_POLICY_SCOPE)

 

放置類別2:

# weng for qgis test folders. 20.4.27

set_target_properties(qgis_${testname} PROPERTIES FOLDER ${QGIS_QGIS_TEST_ROOT_FOLDER}/)

 

 

語言設置:

 

 

 

運行

build 完成后,輸出在 C:\OSGeo4W64\QGIS\build\output\bin\RelWithDebInfo

 

gis 依賴比較多,可通過設置環境變量的方式來運行。以下內容保存為 qgis.bat。
@echo off
set OSGEO4W_ROOT=C:\OSGeo4W64
call "%OSGEO4W_ROOT%\bin\o4w_env.bat"
call "%OSGEO4W_ROOT%\bin\py3_env.bat"
call "%OSGEO4W_ROOT%\bin\qt5_env.bat"
start qgis

雙擊運行 qgis.bat。

問題及解決

(0)CMake問題: ADD_SUBDIRECTORY given source "native" which is not an existing directory.
問題,提示:

CMake Error at src/CMakeLists.txt:1 (ADD_SUBDIRECTORY):

ADD_SUBDIRECTORY given source "native" which is not an existing directory.

 

Found exiv2: D:/Pros/Office/QGIS_Dev/OSGeo4W/lib/exiv2.lib

CMake Error at src/CMakeLists.txt:9 (ADD_SUBDIRECTORY):

ADD_SUBDIRECTORY given source "ui" which is not an existing directory.

 

CMake Error at src/CMakeLists.txt:14 (ADD_SUBDIRECTORY):

ADD_SUBDIRECTORY given source "providers" which is not an existing

directory.

 

CMake Error at src/CMakeLists.txt:22 (ADD_SUBDIRECTORY):

ADD_SUBDIRECTORY given source "test" which is not an existing directory.

 

CMake Error at src/CMakeLists.txt:26 (ADD_SUBDIRECTORY):

ADD_SUBDIRECTORY given source "plugins" which is not an existing directory.

 

CMake Error at src/CMakeLists.txt:34 (ADD_SUBDIRECTORY):

ADD_SUBDIRECTORY given source "python" which is not an existing directory.

 

CMake Error at src/CMakeLists.txt:50 (ADD_SUBDIRECTORY):

ADD_SUBDIRECTORY given source "process" which is not an existing directory.

 

Using PROJ 6 srs database.

CMake Error at CMakeLists.txt:993 (ADD_SUBDIRECTORY):

ADD_SUBDIRECTORY given source "tests" which is not an existing directory.

原因,解壓qgis庫時,發現沒有解壓完整。

 

(1) protobufC++)的使用(windows
https://blog.csdn.net/pengshengli/article/details/90378455
https://github.com/protocolbuffers/protobuf/releases

(2) Qt5Gui_DIR
https://blog.csdn.net/webzhuce/article/details/79960512

WITH_QTWEBKIT 取消
WITH_Qt5SerialPort 取消

修改cmakelist, 新添加如下內容。

set(Qt5Gui_DIR "C:/Program/Dev/Qt/Qt5.13.1/5.13.1/msvc2017_64/lib/cmake/Qt5Gui/")

set(Qt5Widgets_DIR "C:/Program/Dev/Qt/Qt5.13.1/5.13.1/msvc2017_64/lib/cmake/Qt5Widgets/")

set(Qt5Network_DIR "C:/Program/Dev/Qt/Qt5.13.1/5.13.1/msvc2017_64/lib/cmake/Qt5Network/")

 

set(Qt5Xml_DIR "C:/Program/Dev/Qt/Qt5.13.1/5.13.1/msvc2017_64/lib/cmake/Qt5Xml/")

set(Qt5Svg_DIR "C:/Program/Dev/Qt/Qt5.13.1/5.13.1/msvc2017_64/lib/cmake/Qt5Svg/")

set(Qt5Concurrent_DIR "C:/Program/Dev/Qt/Qt5.13.1/5.13.1/msvc2017_64/lib/cmake/Qt5Concurrent/")

set(Qt5PrintSupport_DIR "C:/Program/Dev/Qt/Qt5.13.1/5.13.1/msvc2017_64/lib/cmake/Qt5PrintSupport/")

set(Qt5Positioning_DIR "C:/Program/Dev/Qt/Qt5.13.1/5.13.1/msvc2017_64/lib/cmake/Qt5Positioning/")

 

set(Qt5WebKit_DIR "C:/Program/Dev/Qt/Qt5.13.1/5.13.1/msvc2017_64/lib/cmake/Qt5WebKit/")

set(Qt5WebKitWidgets_DIR "C:/Program/Dev/Qt/Qt5.13.1/5.13.1/msvc2017_64/lib/cmake/Qt5WebKitWidgets/")

 

set(Qt5Test_DIR "C:/Program/Dev/Qt/Qt5.13.1/5.13.1/msvc2017_64/lib/cmake/Qt5Test/")

set(Qt5UiTools_DIR "C:/Program/Dev/Qt/Qt5.13.1/5.13.1/msvc2017_64/lib/cmake/Qt5UiTools/")

set(Qt5Sql_DIR "C:/Program/Dev/Qt/Qt5.13.1/5.13.1/msvc2017_64/lib/cmake/Qt5Sql/")

 

set(Qt53DCore_DIR "C:/Program/Dev/Qt/Qt5.13.1/5.13.1/msvc2017_64/lib/cmake/Qt53DCore/")

set(Qt53DRender_DIR "C:/Program/Dev/Qt/Qt5.13.1/5.13.1/msvc2017_64/lib/cmake/Qt53DRender/")

 

set(Qt53DInput_DIR "C:/Program/Dev/Qt/Qt5.13.1/5.13.1/msvc2017_64/lib/cmake/Qt53DInput/")

set(Qt53DLogic_DIR "C:/Program/Dev/Qt/Qt5.13.1/5.13.1/msvc2017_64/lib/cmake/Qt53DLogic/")

set(Qt53DExtras_DIR "C:/Program/Dev/Qt/Qt5.13.1/5.13.1/msvc2017_64/lib/cmake/Qt53DExtras/")

 

但仍然編譯不通過:

Selecting Windows SDK version 10.0.17763.0 to target Windows 10.0.18363.

QGIS version: 3.13.0 Master (31300)

Found OpenCL C++ headers: E:/Projs/algs/qgis/qgis_source/external/opencl-clhpp/include

Could not find GRASS 7

Found Proj: D:/Pros/Office/QGIS_3_12/lib/proj_i.lib version 6 (6.3.1)

Found GEOS: D:/Pros/Office/QGIS_3_12/lib/geos_c.lib (3.8.0)

Found GDAL: D:/Pros/Office/QGIS_3_12/lib/gdal_i.lib (3.0.4)

Found Expat: D:/Pros/Office/QGIS_3_12/lib/expat.lib

Found Spatialindex: D:/Pros/Office/QGIS_3_12/lib/spatialindex-64.lib

Found libzip: D:\Pros\IDE\VS_LIBS\boost_comp\zlib_install\lib

Found Sqlite3: D:/Pros/Office/QGIS_3_12/lib/sqlite3_i.lib

Found Protobuf: D:\Pros\IDE\VS_LIBS\vcpkg\vcpkg\installed\x64-windows\lib

Found zlib: D:/Pros/Office/QGIS_3_12/lib/zlib.lib

Found PostgreSQL: D:/Pros/Office/QGIS_3_12/lib/libpq.lib

Found SpatiaLite: D:/Pros/Office/QGIS_3_12/lib/spatialite_i.lib

Qt WebKit support DISABLED.

CMake Error at C:/Program/Dev/Qt/Qt5.13.1/5.13.1/msvc2017_64/lib/cmake/Qt5UiTools/Qt5UiToolsConfig.cmake:74 (message):

Library not found: Qt5Cored

Call Stack (most recent call first):

C:/Program/Dev/Qt/Qt5.13.1/5.13.1/msvc2017_64/lib/cmake/Qt5UiTools/Qt5UiToolsConfig.cmake:227 (_qt5_UiTools_process_prl_file)

CMakeLists.txt:444 (FIND_PACKAGE)

 

Configuring incomplete, errors occurred!

See also "E:/Projs/algs/qgis/qgis_build/CMakeFiles/CMakeOutput.log".

See also "E:/Projs/algs/qgis/qgis_build/CMakeFiles/CMakeError.log".

 

解決方法:下載完整的qgis-dev-deps.

 

(3)Could not load qgis_app.dll.

Error loading QGIS

Oops, looks like an error loading Qgis, Details Could not load qgis_app.dll.

Window Erro: The specified procedure could not be found.

Help: Check c:\OS.. qgis-bin.env for correct environmental paths.

 

 

 

解決方法(不可行):

出現這種問題可能是多刪除了項目,保留下面幾個項目。

 

 

(4)問題

E:\Projs\algs\qgis\qgis_source\build\output\bin\Release

 

 

猜測:

是否和 D:\Pros\IDE\VS_LIBS\vcpkg\vcpkg\installed\x64-windows\include__,  中的protobuf重復了。所以,將其include更改,再試一下。

發現不是和上述vcpkg中的protobuf沖突了,而是qgis_core.dll上引用的D:\Pros\Office\QGIS_Dev\OSGeo4W\lib下的"libprotobuf-lite.lib", 將其改為 libprotobuf.lib 即可。

 

 

(5)version編譯失敗。

ModuleNotFoundError: No module named 'PyQt5.pyqtconfig'

1>------ 已啟動生成: 項目: version, 配置: Release x64 ------

1>Building Custom Rule E:/Projs/algs/qgis/qgis_source2/CMakeLists.txt

1>CMake is re-running because E:/Projs/algs/qgis/qgis_source2/build/CMakeFiles/generate.stamp is out-of-date.

1>  the file 'E:/Projs/algs/qgis/qgis_source2/CMakeLists.txt'

1>  is newer than 'E:/Projs/algs/qgis/qgis_source2/build/CMakeFiles/generate.stamp.depend'

1>  result='-1'

1>-- Selecting Windows SDK version 10.0.17763.0 to target Windows 10.0.18363.

1>-- QGIS version: 3.13.0 Master (31300)

1>-- Found OpenCL C++ headers: D:/Pros/Office/QGIS_Dev/OSGeo4W/include

1>-- Could not find GRASS 7

1>-- Found Proj: D:/Pros/Office/QGIS_Dev/OSGeo4W/lib/proj_i.lib version 6 (6.3.1)

1>-- Found GEOS: D:/Pros/Office/QGIS_Dev/OSGeo4W/lib/geos_c.lib (3.8.1)

1>-- Found GDAL: D:/Pros/Office/QGIS_Dev/OSGeo4W/lib/gdal_i.lib (3.0.4)

1>-- Found Expat: D:/Pros/Office/QGIS_Dev/OSGeo4W/lib/expat.lib

1>-- Found Spatialindex: D:/Pros/Office/QGIS_Dev/OSGeo4W/lib/spatialindex-64.lib

1>-- Found Qwt: D:/Pros/Office/QGIS_Dev/OSGeo4W/apps/Qt5/lib/qwt.lib (6.1.3)

1>-- Found libzip: D:/Pros/Office/QGIS_Dev/OSGeo4W/lib/zip.lib

1>-- Found Sqlite3: D:/Pros/Office/QGIS_Dev/OSGeo4W/lib/sqlite3_i.lib

1>-- Found Protobuf: D:/Pros/Office/QGIS_Dev/OSGeo4W/lib/libprotobuf.lib

1>-- Found zlib: D:/Pros/Office/QGIS_Dev/OSGeo4W/lib/zlib.lib

1>-- Found PostgreSQL: D:/Pros/Office/QGIS_Dev/OSGeo4W/lib/libpq.lib

1>-- Found SpatiaLite: D:/Pros/Office/QGIS_Dev/OSGeo4W/lib/spatialite_i.lib

1>-- Qt WebKit support enabled

1>-- Found Qt version: 5.11.2

1>-- Found QScintilla2: D:/Pros/Office/QGIS_Dev/OSGeo4W/apps/Qt5/lib/qscintilla2_qt5.lib (2.10.8)

1>-- Found QtKeychain: D:/Pros/Office/QGIS_Dev/OSGeo4W/apps/Qt5/lib/qt5keychain.lib

1>-- Found QCA: D:/Pros/Office/QGIS_Dev/OSGeo4W/apps/Qt5/lib/qca-qt5.lib (2.1.3)

1>-- Pedantic compiler settings enabled

1>-- Found Python executable: D:/Pros/Office/QGIS_Dev/OSGeo4W/bin/python3.exe

1>-- Found Python version: 3.7.0

1>-- Found Python library: D:/Pros/Office/QGIS_Dev/OSGeo4W/apps/Python37/libs/python37.lib

1>-- Found Python site-packages: D:/Pros/IDE/Python37/Lib/site-packages

1>Traceback (most recent call last):

1>  File "E:/Projs/algs/qgis/qgis_source2/cmake/FindPyQt5.py", line 34, in <module>

1>    import PyQt5.pyqtconfig

1>ModuleNotFoundError: No module named 'PyQt5.pyqtconfig'

1>

1>During handling of the above exception, another exception occurred:

1>

1>Traceback (most recent call last):

1>  File "E:/Projs/algs/qgis/qgis_source2/cmake/FindPyQt5.py", line 38, in <module>

1>    import sipconfig # won't work for SIP v5

1>ModuleNotFoundError: No module named 'sipconfig'

1>Traceback (most recent call last):

1>  File "E:/Projs/algs/qgis/qgis_source2/cmake/FindSIP.py", line 33, in <module>

1>    import sipconfig

1>ModuleNotFoundError: No module named 'sipconfig'

1>CMake Error at cmake/FindSIP.cmake:54 (MESSAGE):

1>  Could not find SIP

1>Call Stack (most recent call first):

1>  CMakeLists.txt:891 (FIND_PACKAGE)

1>

1>

1>-- Configuring incomplete, errors occurred!

1>See also "E:/Projs/algs/qgis/qgis_source2/build/CMakeFiles/CMakeOutput.log".

1>See also "E:/Projs/algs/qgis/qgis_source2/build/CMakeFiles/CMakeError.log".

1>C:\Program\Dev\Microsoft Visual Studio\2017\Enterprise\Common7\IDE\VC\VCTargets\Microsoft.CppCommon.targets(209,5): error MSB6006: “cmd.exe”已退出,代碼為 1。

1>已完成生成項目“version.vcxproj”的操作 - 失敗。

 

移除完,不相干的內容。再去編譯。

 

(6)Couldn't load SIP module.

 

解決方法:

D:\Pros\Office\QGIS_Dev\OSGeo4W\apps\Python37>python Scripts/pip.exe list

查看列出的結果(左側)。

D:\Pros\Office\QGIS_Dev\OSGeo4W\apps\Python37>python Scripts/pip.exe list

Package           Version

----------------- ---------

bleach            3.1.0

certifi           2019.9.11

chardet           3.0.4

coverage          4.5.1

cycler            0.10.0

docutils          0.15.2

future            0.16.0

GDAL              3.0.4

idna              2.8

kiwisolver        1.1.0

matplotlib        3.1.3

mock              2.0.0

nose2             0.8.0

numpy             1.18.1

pbr               4.3.0

Pillow            5.3.0

pip               20.0.2

pkginfo           1.5.0.1

ply               3.11

psycopg2-binary   2.8.4

Pygments          2.4.2

PyOpenGL          3.1.0

pyparsing         2.4.6

PyQt5             5.11.3

python-dateutil   2.8.1

pywin32           224

PyYAML            5.3

readme-renderer   24.0

requests          2.22.0

requests-toolbelt 0.9.1

setuptools        41.2.0

sip               4.19.14

six               1.12.0

tqdm              4.36.1

twine             1.15.0

urllib3           1.25.5

webencodings      0.5.1

wheel             0.33.6

wxPython          4.0.7

WARNING: pip is configured with locations that require TLS/SSL, however the ssl module in Python is not available.

Could not fetch URL https://pypi.org/simple/pip/: There was a problem confirming the ssl certificate: HTTPSConnectionPool(host='pypi.org', port=443): Max retries exceeded with url: /simple/pip/ (Caused by SSLError("Can't connect to HTTPS URL because the SSL module is not available.")) - skipping

 

D:\Pros\Office\QGIS_Dev\OSGeo4W\apps\Python37>

D:\Pros\Office\QGIS_3_12\apps\Python37>python Scripts/pip.exe list

Package           Version

----------------- ---------

bleach            3.1.0

certifi           2019.9.11

chardet           3.0.4

coverage          4.5.1

cycler            0.10.0

decorator         4.4.1

docutils          0.15.2

ExifRead          2.1.2

future            0.16.0

GDAL              3.0.4

geographiclib     1.50

httplib2          0.11.3

idna              2.8

ipython-genutils  0.2.0

Jinja2            2.11.1

jsonschema        2.6.0

jupyter-core      4.4.0

kiwisolver        1.1.0

lxml              4.3.3

MarkupSafe        1.1.1

matplotlib        3.1.3

mock              2.0.0

nbformat          4.4.0

networkx          2.2

nose2             0.8.0

numpy             1.18.1

OWSLib            0.17.0

pandas            1.0.1

pbr               4.3.0

Pillow            5.3.0

pip               20.0.2

pkginfo           1.5.0.1

plotly            3.3.0

ply               3.11

psycopg2-binary   2.8.4

Pygments          2.4.2

pyodbc            4.0.24

PyOpenGL          3.1.0

pyparsing         2.4.6

pypiwin32         223

pyproj            2.5.0

PyQt5             5.11.3

python-dateutil   2.8.1

pytz              2019.3

pywin32           224

PyYAML            5.3

readme-renderer   24.0

requests          2.22.0

requests-toolbelt 0.9.1

retrying          1.3.3

scipy             1.4.1

setuptools        41.2.0

Shapely           1.7.0

simplejson        3.16.0

sip               4.19.14

six               1.12.0

tqdm              4.36.1

traitlets         4.3.3

twine             1.15.0

urllib3           1.25.5

webencodings      0.5.1

wheel             0.33.6

wxPython          4.0.7

xlrd              1.1.0

xlwt              1.3.0

WARNING: pip is configured with locations that require TLS/SSL, however the ssl module in Python is not available.

Could not fetch URL https://pypi.org/simple/pip/: There was a problem confirming the ssl certificate: HTTPSConnectionPool(host='pypi.org', port=443): Max retries exceeded with url: /simple/pip/ (Caused by SSLError("Can't connect to HTTPS URL because the SSL module is not available.")) - skipping

 

D:\Pros\Office\QGIS_3_12\apps\Python37>

 

可以看到本該有的PyQt文件夾,沒有在編譯安裝時,生成。

解決方法是,全部生成QGIS目錄下原本有的項目。不要取消生成一部分項目,以提高所謂的生成速度。

而此時,千萬不要聽信網上的方法,刪除 C:\Users\Administrator\AppData\Roaming\QGIS 下的QGIS3文件夾。

否則,你的個性化設置,將全部丟失。

 

 

(7)其它python所依賴的第三方庫找不到的話,可以pip安裝

D:\Pros\Office\QGIS_Dev\OSGeo4W\apps\Python37>python Scripts/pip.exe install jinja2 -i http://pypi.douban.com/simple --trusted-host pypi.douban.com

 

(8)processing 菜單消失,processing box工具箱找不到

Plugin processing: The plugin will be disabled because it crashed QGIS during last startup. Please report an issue and re-enable the plugin when the problem has been solved.

 

 

可以在這個地方,看到QGIS的配置信息。

C:\Users\Administrator\AppData\Roaming\QGIS\QGIS3\profiles\default\QGIS\QGIS3.ini

 

解決方法:

在插件,已經安裝的插件中,重新開啟processing,這個核心的插件。

 

3.2 Packaging

To create a standalone installer there is a perl script named 'creatensis.pl' in 'qgis/ms-windows/osgeo4w'. It downloads all required packages from OSGeo4W and repackages them into an installer using NSIS.

The script can be run on both Windows and Linux.

On Debian/Ubuntu you can just install the 'nsis' package.

NSIS for Windows can be downloaded at:

http://nsis.sourceforge.net

And Perl for Windows (including other requirements like 'wget', 'unzip', 'tar' and 'bzip2') is available at:

http://cygwin.com

 

3.3 Packaging your own build of QGIS

Assuming you have completed the above packaging step, if you want to include your own hand built QGIS executables, you need to copy them in from your windows installation into the ms-windows file tree created by the creatensis script.

cd ms-windows/
rm -rf osgeo4w/unpacked/apps/qgis/*
cp -r /tmp/qgis1.7.0/* osgeo4w/unpacked/apps/qgis/

Now create a package.

./quickpackage.sh

After this you should now have a nsis installer containing your own build of QGIS and all dependencies needed to run it on a windows machine.

 

3.4 Osgeo4w packaging

The actual packaging process is currently not documented, for now please take a look at:

ms-windows/osgeo4w/package.cmd

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM