我的github

注意更新时间: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:免费的社区版安装器如下所示:

http://download.microsoft.com/download/D/2/3/D23F4D0F-BA2D-4600-8725-6CCECEA05196/vs_community_ENU.exe

4.1.2. Other tools and dependencies其他工具和依赖库

Download and install following packages:下载并安装如下的包:

Tool

Website

CMake

https://cmake.org/files/v3.7/cmake-3.7.2-win64-x64.msi

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:

http://nsis.sourceforge.net

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

http://cygwin.com

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

posted on 2017-11-14 20:38  XiaoNiuFeiTian  阅读(3118)  评论(0编辑  收藏  举报