注意更新時間:Thursday November 02, 2017
1. Introduction 簡介
This document is the original installation guide of the described software QGIS. The software and hardware descriptions named in this document are in most cases registered trademarks and are therefore subject to the legal requirements. QGIS is subject to the GNU General Public License. Find more information on the QGIS Homepage: http://qgis.org
該文檔是QGIS原始安裝指南。在本文檔中指名的軟件和硬件描述在大多數情況下是注冊商標並且符合合法描述的。QGIS是符合GNU通用公共許可的。在QGIS主頁查找更多信息:http://qgis.org。
The details, that are given in this document have been written and verified to the best of knowledge and responsibility of the editors. Nevertheless, mistakes concerning the content are possible. Therefore, all data are not liable to any duties or guarantees. The editors and publishers do not take any responsibility or liability for failures and their consequences. You are always welcome for indicating possible mistakes.
Because the code of QGIS evolves from release to release, These instructions are regularly updated to match the corresponding release. Instructions for the current master branch are available at http://htmlpreview.github.io/?https://raw.github.com/qgis/QGIS/master/doc/INSTALL.html. If you wish to build another version of QGIS, ensure to checkout the appropriate release branch. The QGIS source code can be found in the repository.
由於QGIS的代碼是隨着每一版本而進化的。這些指導一般更新以符合相應的版本。當前的主分支指導可以在:http://htmlpreview.github.io/?https://raw.github.com/qgis/QGIS/master/doc/INSTALL.html.。如果你希望編譯另一版本的QGIS的話,請確保符合相應的版本分支。QGIS源代碼可以在這里找到。
Please visit http://qgis.org for information on joining our mailing lists and getting involved in the project further.
請訪問http://qgis.org查找融合我們的郵箱列表並融入我們的項目的信息。
/!\ Note to document writers: Please use this document as the central place for describing build procedures. Please do not remove this notice.
/!\ Note to document writers: This document is generated from doc/INSTALL.t2t - if you need to edit this document, be sure to edit that file rather than the generated INSTALL document found in the root of the source directory.
2. Overview 概述
QGIS, like a number of major projects (e.g., KDE 4.0), uses CMake (http://www.cmake.org) for building from source.
QGIS,如大量的大工程(比如,KDE4.0),使用CMake(http://www.cmake.org)編譯代碼。
Following a summary of the required dependencies for building:
遵照編譯需要的依賴總結:
Required build tools:需要的編譯工具:
- CMake >= 3.0.0
- Flex >= 2.5.6
- Bison >= 2.4
Required build dependencies:
- Qt >= 5.3.0
- Proj >= 4.4.x
- GEOS >= 3.4
- Sqlite3 >= 3.0.0
- SpatiaLite
- 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.3
- 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.
4. Building on Windows 在Windows上編譯
4.1. Building with Microsoft Visual Studio 使用VS編譯
This section describes how to build QGIS using Visual Studio on Windows. This is currently also how 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.
這一部分描述了如何使用VS在Windows上編譯QGIS。這目前也是二進制QGIS包如何編譯的(早前版本是用MinGW)。
這一部分描述了使用VS編譯QGIS的安裝步驟。
4.1.1. Visual C++ Community Edition 社區版VC++
The free (as in free beer) Community installer is available under:免費的社區版安裝器如下所示:
4.1.2. Other tools and dependencies其他工具和依賴庫
Download and install following packages:下載並安裝如下的包:
Tool |
Website |
CMake |
|
GNU flex, GNU bison and GIT |
http://cygwin.com/setup-x86.exe (32bit) or http://cygwin.com/setup-x86_64.exe (64bit) |
OSGeo4W |
http://download.osgeo.org/osgeo4w/osgeo4w-setup-x86.exe (32bit) or http://download.osgeo.org/osgeo4w/osgeo4w-setup-x86_64.exe (64bit) |
ninja |
https://github.com/ninja-build/ninja/releases/download/v1.7.2/ninja-win.zip |
OSGeo4W does not only provide ready packages for the current QGIS release and nightly builds of master, but also offers most of the dependencies needs to build it.
For the QGIS build you need to install following packages from cygwin: 對於QGIS編譯你需要從cygwin中安裝以下包:
- bison>= 2.4
- flex>= 2.5.6
- git
and from OSGeo4W (select Advanced Installation): 以及從OSGeo4W中(選擇Advanced高級安裝):
- expat>= 1.95
- fcgi
- gdal>= 2.1
- grass
- gsl-devel
- iconv
- libzip-devel
- libspatialindex-devel
- pyqt5
- python3-devel
- python3-qscintilla
- python3-nose2
- python3-future
- python3-pyyaml
- python3-mock
- python3-six
- qca-qt5-devel
- qca-qt5-libs
- qscintilla-qt5
- qt5-devel
- qt5-libs-debug
- qtwebkit-qt5-devel
- qtwebkit-qt5-libs-debug
- qwt-devel-qt5
- sip-qt5
- spatialite>=4.2.0
- oci
- qtkeychain
- libzip
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 virtuallayer provider.
如果你安裝其它的包,可能會引發問題。尤其是,確保不要安裝msinttypes包。它安裝stdint.h文件在OSGeo4W[64]\include中。
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.
該文檔的早期版本還講述了如何編譯上述的依賴。如果你感興趣的話,可以查看維基或SVN托管上的該頁面的歷史記錄。
4.1.3. Setting up the Visual Studio project with CMake使用CMake創建Visual Studio項目
/!\ Consider this section as example. It tends to outdate, when OSGeo4W and SDKs move on. ms-windows/osgeo4w/package-nightly.cmd is used for the nightly builds and constantly updated and hence might contain necessary updates that are not yet reflected here.
注意:請把該部分當成示例。它傾向於過時,因為OSGeo4W和SDK包總是進化的。ms-windows/osgeo4w/package-nightly.cmd用來最新的編譯和不斷地更新,因此可能包含必須的更新(這里可能還沒來得及反應)。
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):
要啟動一個命令提示符(在同時擁有VC++和OSGeo4W變量符的環境),創建如下的batch文件(假設上述的包已經在默認的路徑下安裝)(batch文件后綴名為.bat):
@echo off set OSGEO4W_ROOT=C:\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% call "C:\Program Files\Microsoft Visual Studio 14.0\VC\vcvarsall.bat" amd64 path %path%;C:\Program Files\Microsoft Visual Studio 14.0\VC\bin path %PATH%;C:\Program Files\CMake\bin;c:\cygwin\bin @set GRASS_PREFIX=c:/OSGeo4W/apps/grass/grass-7.2.1 @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
Start the batch file and on the command prompt checkout the QGIS source from git to the source directory QGIS:
啟動batch文件,而且在命令提示符中從git獲取QGIS源代碼到源路徑QGIS:
git clone git://github.com/qgis/QGIS.git
Create a 'build' directory somewhere. This will be where all the build output will be generated.
在某個地方創建一個'build'目錄。這將是編譯輸出將生成的地方。
Now run cmake-gui (still from cmd) and in the Where is the source code: box, browse to the top level QGIS directory.
現在運行cmake-gui(依然是從cmd中運行)然后在Where is the source code:方框里,瀏覽到QGIS目錄的最上層。
In the Where to build the binaries: box, browse to the 'build' directory you created.
在Where to build the binaries:方框里,瀏覽到你創建的'build'目錄。
If the path to bison and flex contains blanks, you need to use the short name for the directory (i.e. C:\Program Files should be rewritten to C:\Progra~n, where n is the number as shown in `dir /x C:\``).
如果bison和flex的路徑包含空格,你需要使用目錄的短名稱(例如:C:\Program Files應該重寫成C:\Progra~n,這里n是在'dir /x C:\''顯示的數字)。
Verify that the 'BINDINGS_GLOBAL_INSTALL' option is not checked, so that python bindings are placed into the output directory when you run the INSTALL target.
驗證'BINDINGS_GLOBAL_INSTALL'選項沒有選上,從而當你運行INSTALL目標時python bindings被放置在輸出目錄。
Hit Configure to start the configuration and select Visual Studio 9 2008 and keep native compilers and click Finish.
按下Configure鍵開始配置並且選擇Visual Studio 9 2008並保持native compilers然后點擊Finish。
The configuration should complete without any further questions and allow you to click Generate.
配置應該是沒有問題的,並允許你點擊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.
現在關閉cmake-gui然后繼續命令提示行啟動vcexpress。使用File / Open / Project/Solutions然后打開你的項目目錄下的qgis-x.y.z.sln文件。
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).
更改方案配置從Debug到RelWithDebInfo(Release with Debug Info)或者是Release,在你使用ALL_BUILD目標編譯QGIS(否則你需要編譯類庫,那暫時還並沒有包含進來)。
After the build completed you should install QGIS using the INSTALL target.
運行完ALL_BUILD之后你應該使用INSTALL安裝QGIS。
Install QGIS by building the INSTALL project. By default this will install to c:\Program Files\qgis<version> (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.
4.1.4. 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:
And Perl for Windows (including other requirements like 'wget', 'unzip', 'tar' and 'bzip2') is available at:
4.1.5. 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.
4.1.6. Osgeo4w packaging
The actual packaging process is currently not documented, for now please take a look at:
ms-windows/osgeo4w/package.cmd
本文轉自:https://htmlpreview.github.io/?https://raw.github.com/qgis/QGIS/master/doc/INSTALL.html#toc14
>>QGIS官網:http://www.qgis.org
>>QGIS托管:https://github.com/qgis/QGIS
一定要在運行a.bat之后的彈出的cmd.exe里使用cmake-gui打開CMAKE
這里面的幾個類庫你都熟悉了嗎?
而且注意是64位!!!
>>若實在編譯不成功,可以直接調用官方已經編譯好的sdk:https://blog.csdn.net/xiongjia516/article/details/81668665