官方QGis 编译帮助,源码工程中的Install文档。后面会放出我翻译的。


 1.Introduction

  ===============

   Thisdocument is the original installation guide of the described software QGIS. Thesoftware and hardware descriptions named in this document are in most casesregistered trademarks and are therefore subject to the legal requirements. QGISis subject to the GNU General Public License. Find more information on the QGISHomepage:http://qgis.org

   Thedetails, that are given in this document have been written and verified to thebest of knowledge and responsibility of the editors. Nevertheless, mistakesconcerning the content are possible. Therefore, all data are not liable to anyduties or uarantees. The editors and publishers do not take any responsibilityor liability for failures and their consequences. You are always welcome forindicating possible mistakes.Youcan download this document as part of the QGIS 'User and Installation Guide' inHTML and PDF format viahttp://qgis.org. A current version is also available at:

http://htmlpreview.github.io/?https://raw.github.com/qgis/QGIS/master/doc/INSTALL.html

Translations of this document can also be downloaded at thedocumentation area of the QGIS project athttp://qgis.org. More information isavailable viahttp://qgis.org/en/site/getinvolved/governance/organisation/governance.html#community-resources.   

   Pleasevisit http://qgis.org for information on joining our mailing lists and getting involvedin the project further.

 

/!\ Note to document writers: Please usethis document as the centralplacefor describing build procedures. Please do not remove this notice.

/!\ Note to document writers: Thisdocumented is generated from doc/INSTALL.t2t - if you need to edit thisdocument, be sure toedit thatfile rather than the generated INSTALL document found in the root of the sourcedirectory.

 

  2.Overview

  ===========

   QGIS,like a number of major projects (eg. KDE 4.0), usesCmake(http://www.cmake.org) for building fromsource.Following a summary ofthe required dependencies for building:

   Requiredbuild tools:

- CMake >= 2.8.0

- Flex

- Bison >= 2.4

Required build deps:

- Qt >= 4.7.0

- Proj >= 4.4.x

- GEOS >= 3.0

- Sqlite3 >= 3.0.0

- GDAL/OGR >= 1.4.x

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

- expat >= 1.95

Optional dependencies:

- for GRASS plugin - GRASS >= 6.0.0 (libraries compiledwith exceptions support on Linux 32bit)

- for georeferencer - GSL >= 1.8

- for postgis support and SPIT plugin - PostgreSQL >=8.0.x

- for gps plugin - gpsbabel

- for mapserver export and PyQGIS - Python >= 2.3 (2.5+preferred)

- for python support - SIP >= 4.12, PyQt >= 4.8.3 mustmatch Qt version, Qscintilla2

- for qgis mapserver - FastCGI

 

3. Building on Windows

  ======================

 

  3.1.Building with Microsoft Visual Studio

  ==========================================

   Thissection describes how to build QGIS using Visual Studio on Windows.  Thisis currently also how the binary QGIS packages are made (earlierversions usedMinGW).

   Thissection describes the setup required to allow Visual Studio to be used tobuild QGIS.

 

    3.1.1. Visual C++ Express Edition

    =================================

   Thefree (as in free beer) Express Edition installer is available under:http://download.microsoft.com/download/d/c/3/dc3439e7-5533-4f4c-9ba0-8577685b6e7e/vcsetup.exe .The optional products are notnecessary.  In the process the WindowsSDKs forVisual Studio 2008will also be downloaded and installed.You also need the Microsoft Windows Server(R) 2003 R2 Platform SDK(for setupapi):

  http://download.microsoft.com/download/f/a/d/fad9efde-8627-4e7a-8812-c351ba099151/PSDK-x86.exe .You only need Microsoft Windows Core SDK /Build Environment (x86 32-Bit).

 

    3.1.2. Other tools and dependencies

    ===================================

Download and install following packages:

   || Tool | Website |

   | CMake |http://www.cmake.org/files/v2.8/cmake-2.8.4-win32-x86.exe |

   | Flex |http://gnuwin32.sourceforge.net/downlinks/flex.php |

   | Bison |http://gnuwin32.sourceforge.net/downlinks/bison.php |

   | SVN |http://sourceforge.net/projects/win32svn/files/1.6.13/Setup-Subversion-1.6.13.msi/download |

   | or GIT |http://msysgit.googlecode.com/files/Git-1.7.4-preview20110204.exe |

   | OSGeo4W |http://download.osgeo.org/osgeo4w/osgeo4w-setup.exe |

   OSGeo4Wdoes not only provide ready packages for the current QGIS release andnightly builds of the trunk, but alsooffers most of the dependencies needs tobuild it. For theQGIS build you need to install following packages from OSGeo4W (select

AdvancedInstallation):

- expat

- fcgi

- gdal

- grass

- gsl-devel

- iconv

- pyqt4

- qt4-devel

- qwt5-devel-qt4

- sip

- spatialite

- libspatialindex-devel

- python-qscintilla

   Thiswill also select packages the above packages depend on.Additionally QGIS also needs the include file unistd.h,which normallydoesn't exist onWindows.  It's shipped with Flex/Bison inGnuWin32\includeand needs tobe copied into the VC\include directory of your Visual C++installation.

   Earlierversions of this document also covered how to build all abovedependencies.  If you're interested in that, check thehistory of this page in the Wikior the SVN repository.

 

    3.1.3. Setting up the Visual Studio project with CMake

    ======================================================

   Tostart a command prompt with an environment that both has the VC++ and theOSGeo4Wvariables create thefollowing batch file (assuming the above packages wereinstalled in the default locations):

     @echo off

     path%SYSTEMROOT%\system32;%SYSTEMROOT%;%SYSTEMROOT%\System32\Wbem;%PROGRAMFILES%\CMake2.8\bin;%PROGRAMFILES%\subversion\bin;%PROGRAMFILES%\GnuWin32\bin

     set PYTHONPATH=

  

     setVS90COMNTOOLS=%PROGRAMFILES%\Microsoft Visual Studio 9.0\Common7\Tools\

     call"%PROGRAMFILES%\Microsoft Visual Studio 9.0\VC\vcvarsall.bat" x86

  

     setINCLUDE=%INCLUDE%;%PROGRAMFILES%\Microsoft Platform SDK for Windows Server 2003R2\include

     setLIB=%LIB%;%PROGRAMFILES%\Microsoft Platform SDK for Windows Server 2003 R2\lib

  

     setOSGEO4W_ROOT=C:\OSGeo4W

     call"%OSGEO4W_ROOT%\bin\o4w_env.bat"

  

     @setGRASS_PREFIX=c:/OSGeo4W/apps/grass/grass-6.4.0

     @setINCLUDE=%INCLUDE%;%OSGEO4W_ROOT%\include

     @setLIB=%LIB%;%OSGEO4W_ROOT%\lib;%OSGEO4W_ROOT%\lib

  

     @cmd

   Startthe batch file and on the command prompt checkout the QGIS source fromgit to the source directory QGIS:git clone git://github.com/qgis/QGIS.git . Create a 'build' directory somewhere.This will be where all the build outputwill be generated. Nowrun cmake-gui (still from cmd) and in the Where is the source code:box, browse to the top level QGISdirectory.In the Where tobuild the binaries: box, browse to the 'build' directory youcreated.

   Ifthe path to bison and flex contains blanks, you need to use the short namefor the directory (i.e. C:\Program Filesshould be rewritten toC:\Progra~n,where n is the number as shown in `dir /x C:\``).Verify that the 'BINDINGS_GLOBAL_INSTALL' option is not checked, sothat pythonbindings are placedinto the output directory when you run the INSTALL target.Hit Configure to start the configurationand select Visual Studio 9 2008and keep native compilers and click Finish.The configuration should complete without any further questions andallow you toclick Generate. Now close cmake-gui and continue on thecommand prompt by starting

vcexpress.  Use File / Open / Project/Solutions and openthe

qgis-x.y.z.slnFile in your project directory.

ChangeSolution Configuration from Debug to RelWithDebInfo (Release

with DebugInfo)  or Release before you build QGISusing the ALL_BUILD

target(otherwise you need debug libraries that are not included).

After thebuild completed you should install QGIS using the INSTALL target.

InstallQGIS by building the INSTALL project. By default this will install to

c:\ProgramFiles\qgis<version> (this can be changed by changing the

CMAKE_INSTALL_PREFIXvariable in cmake-gui).

You willalso either need to add all the dependency DLLs to the QGIS install

directoryor add their respective directories to your PATH.

 

    3.1.4. Packaging

    ================

   Tocreate a standalone installer there is a perl script named 'creatensis.pl'in 'qgis/ms-windows/osgeo4w'.  It downloads allrequired packages from OSGeo4Wand repackages them into an installer using NSIS.The script can be run on both Windows andLinux.On Debian/Ubuntu you canjust install the 'nsis' package.

   NSISfor Windows can be downloaded at:http://nsis.sourceforge.net

   AndPerl for Windows (including other requirements like 'wget', 'unzip', 'tar'and 'bzip2') is available at: http://cygwin.com

 

    3.1.5. Packaging your own build of QGIS

    =======================================

   Assumingyou have completed the above packaging step, if you want to includeyour own hand built QGIS executables, youneed to copy them in from yourwindowsinstallation into the ms-windows file tree created by the creatensisscript.

      cd ms-windows/

      rm -rfosgeo4w/unpacked/apps/qgis/*

      cp -r/tmp/qgis1.7.0/* osgeo4w/unpacked/apps/qgis/

Now createa package.

     ./quickpackage.sh

After this you should now have a nsis installer containing your ownbuildof QGIS and alldependencies needed to run it on a windows machine.

 

    3.1.6. Osgeo4w packaging

    ========================

The actual packaging process is currently not documented, for nowplease take alook at: ms-windows/osgeo4w/package.cmd

 

  3.2.Building using MinGW

  =========================

Note: This section might be outdated as nowadays Visual C++ is useto buildthe"official" packages.

Note: For a detailed account of building all the dependenciesyourself youcan visit MarcoPasetti's website here:

http://www.webalice.it/marco.pasetti/qgis+grass/BuildFromSource.html

Read on touse the simplified approach with pre-built libraries...

 

    3.2.1. MSYS

    ===========

   MSYSprovides a unix style build environment under windows. We have created azip archive that contains just about alldependencies. Get this:

http://download.osgeo.org/qgis/win32/msys.zip

and unpackto c:\msys

   Ifyou wish to prepare your msys environment yourself rather than using ourpre-made one, detailed instructions are provided elsewhere in thisdocument.

 

    3.2.2.Qt

    =========

   DownloadQt opensource precompiled edition exe and install (including thedownload and install of mingw) from here:

http://qt.nokia.com/downloads/When the installer will ask for MinGW, youdon't need to download and installit, just point the installer to c:\msys\mingwWhen Qt installation is complete:

Edit C:\Qt\4.7.0\bin\qtvars.bat and add the following lines:

     setPATH=%PATH%;C:\msys\local\bin;c:\msys\local\lib

     setPATH=%PATH%;"C:\Program Files\Subversion\bin"

I suggest you also add C:\Qt\4.7.0\bin\ to your EnvironmentVariables Path inthe windowssystem preferences.

If you plan to do some debugging, you'll need to compile debugversion of Qt:C:\Qt\4.7.0\bin\qtvars.batcompile_debug

Note: there is a problem when compilingdebug version of Qt 4.7, the script ends withthis message "mingw32-make: *** No rule     

      to make target `debug'. Stop.". To

compile the debug version you have to go out of src directory andexecute thefollowing command:

  c:\Qt\4.7.0make

 

    3.2.3. Flex and Bison

    =====================

   GetFlex: http://sourceforge.net/project/showfiles.php?group_id=23617&package_id=16424(the zip bin) and extract it intoc:\msys\mingw\bin

 

    3.2.4. Python stuff (optional)

    ==============================

   Followthis section in case you would like to use Python bindings for QGIS.  Tobe able to compile bindings, you need to compile SIP and PyQt4 fromsources astheir installerdoesn't include some development files which are necessary.

 

      3.2.4.1. Download and install Python - use Windows installer

      ============================================================

    (Itdoesn't matter to what folder you'll install it)http://python.org/download/

 

      3.2.4.2. Download SIP and PyQt4 sources

      =======================================

   http://www.riverbankcomputing.com/software/sip/download

   http://www.riverbankcomputing.com/software/pyqt/download

   Extracteach of the above zip files in a temporary directory. Make sureto get versions that match your current Qtinstalled version.

 

      3.2.4.3. Compile SIP

      ====================

  c:\Qt\4.7.0\bin\qtvars.bat

  python configure.py -p win32-g++

  make

  make install

 

      3.2.4.4. Compile PyQt

      =====================

  c:\Qt\4.7.0\bin\qtvars.bat

  python configure.py

  make

  make install

 

      3.2.4.5. Final python notes

      ===========================

/!\ You can delete the directories with unpacked SIP andPyQt4 sources after a

successfull install, they're not needed anymore.

 

    3.2.5. git

    ==========

    Inorder to check out QGIS sources from the repository, you need a git client.This installer should work fine:

    http://msysgit.googlecode.com/files/Git-1.7.4-preview20110204.exe

 

    3.2.6. CMake

    ============

   CMakeis build system used by QGIS. Download it from here:http://www.cmake.org/files/v2.8/cmake-2.8.2-win32-x86.exe

 

    3.2.7. QGIS

    ===========

   Starta cmd.exe window ( Start -> Run -> cmd.exe ) Create development directoryand move into it

  md c:\dev\cpp

  cd c:\dev\cpp

   Checkout sources from GIT: git clonegit://github.com/qgis/QGIS.git

 

    3.2.8. Compiling

    ================

   Asa background read the generic building with CMake notes at the end of thisdocument.Start a cmd.exewindow ( Start -> Run -> cmd.exe ) if you don't have onealready. Add paths to compiler and our MSYS environment:

  c:\Qt\4.7.0\bin\qtvars.bat

   Forease of use add c:\Qt\4.7.0\bin\ to your system path in systemproperties so you can just type qtvars.batwhen you open the cmd console.

   Createbuild directory and set it as current directory:

  cd c:\dev\cpp\qgis

  md build

  cd build

 

    3.2.9. Configuration

    ====================

   cmakesetup.. 

   Note:You must include the '..' above.

   Click'Configure' button.  When asked, youshould choose 'MinGW Makefiles' asgenerator. There's aproblem with MinGW Makefiles on Win2K. If you're compiling on thisplatform, use 'MSYS Makefiles' generatorinstead.All dependenciesshould be picked up automatically, if you have set up thePaths correctly. The only thing you need tochange is the installationdestination(CMAKE_INSTALL_PREFIX) and/or set 'Debug'.

   Forcompatibility with NSIS packaging scripts I recommend to leave the installprefix to its default c:\program files\When configuration is done, click 'OK' toexit the setup utility.

 

    3.2.10. Compilation and installation

    ====================================

   makemake install

 

    3.2.11. Run qgis.exe from the directory where it's installed(CMAKE_INSTALL_PREFIX)

    ===================================================================================

   Makesure to copy all .dll:s needed to the same directory as the qgis.exebinary is installed to, if not already doneso, otherwise QGIS will complainabout missing libraries when started.A possibility is to run qgis.exe when your path containsc:\msys\local\bin and

c:\msys\local\lib directories, so theDLLs will be used from that place.

 

    3.2.12. Create the installation package: (optional)

    ===================================================

   Downloadand install NSIS from (http://nsis.sourceforge.net/Main_Page)Now using windows explorer, enter thewin_build directory in your QGIS sourcetree. Read the READMEfile there and follow the instructions. Nextright clickon qgis.nsi andchoose the option 'Compile NSIS Script'.

 

  3.3.Creation of MSYS environment for compilation of QGIS

  =========================================================

 

    3.3.1. Initial setup

    ====================

 

      3.3.1.1. MSYS

      =============

   Thisis the environment that supplies many utilities from UNIX world in Windows andis neededby many dependenciesto be able to compile.Downloadfrom here:

  http://puzzle.dl.sourceforge.net/sourceforge/mingw/MSYS-1.0.11-2004.04.30-1.exe

Install toc:\msys

All stuffwe're going to compile is going to get to this directory (resp. its subdirs).

 

      3.3.1.2. MinGW

      ==============

   Downloadfrom here: http://puzzle.dl.sourceforge.net/sourceforge/mingw/MinGW-5.1.3.exe . Install to c:\msys\mingw

Itsuffices to download and install only g++ and mingw-make components.

 

      3.3.1.3. Flex and Bison

      =======================

   Flexand Bison are tools for generation of parsers, they're needed for GRASS andalso QGIS compilation.Downloadthe following packages:

  http://gnuwin32.sourceforge.net/downlinks/flex-bin-zip.php

  http://gnuwin32.sourceforge.net/downlinks/bison-bin-zip.php

  http://gnuwin32.sourceforge.net/downlinks/bison-dep-zip.php

   Unpackthem all toc:\msys\local

 

    3.3.2. Installing dependencies

    ==============================

 

      3.3.2.1. Getting ready

      ======================

Paul Kelly did a great job and prepared apackage of precompiled libraries for GRASS.The package currently includes:

- zlib-1.2.3

- libpng-1.2.16-noconfig

- xdr-4.0-mingw2

- freetype-2.3.4

- fftw-2.1.5

- PDCurses-3.1

- proj-4.5.0

- gdal-1.4.1

It's available for download here:   http://www.stjohnspoint.co.uk/grass/wingrass-extralibs.tar.gz

Moreover he also left the notes how tocompile it (for those interested):  http://www.stjohnspoint.co.uk/grass/README.extralibs

Unpack thewhole package toc:\msys\local

 

      3.3.2.2. GRASS

      ==============

Grab sources from CVS or use a weekly snapshot,see:  http://grass.itc.it/devel/cvs.php

In MSYS console go to the directory whereyou've unpacked or checked out sources(e.g. c:\msys\local\src\grass-6.3.cvs)

Run thesecommands:

  exportPATH="/usr/local/bin:/usr/local/lib:$PATH"

  ./configure --prefix=/usr/local--bindir=/usr/local --with-includes=/usr/local/include--with-libs=/usr/local/lib --with-cxx --without-jpeg \

  --without-tiff --with-postgres=yes--with-postgres-includes=/local/pgsql/include--with-pgsql-libs=/local/pgsql/lib --with-opengl=windows --with-fftw \

  --with-freetype--with-freetype-includes=/mingw/include/freetype2 --without-x --without-tcltk--enable-x11=no --enable-shared=yes \

  --with-proj-share=/usr/local/share/proj

  make

  make install

It should get installed to c:\msys\local\grass-6.3.cvs

By the way, these pages might be useful:

- http://grass.gdf-hannover.de/wiki/WinGRASS_Current_Status

- http://geni.ath.cx/grass.html

 

      3.3.2.3. GEOS

      =============

Download the sources:  http://geos.refractions.net/geos-2.2.3.tar.bz2

Unpack to e.g. c:\msys\local\src .To compile, I had to patch the sources: infilesource/headers/timeval.h line 13.Change itfrom:

     #ifdef _WIN32

to:

     #ifdefined(_WIN32) && defined(_MSC_VER)

Now, in MSYS console, go to the source directory and run:

     ./configure--prefix=/usr/local

     make

     make install

 

      3.3.2.4. SQLITE

      ===============

You can use precompiled DLL, no need to compile from source:

Download this archive:   http://www.sqlite.org/sqlitedll-3_3_17.zipand copy sqlite3.dll from it to c:\msys\local\lib.Then download this archive:  http://www.sqlite.org/sqlite-source-3_3_17.zipand copy sqlite3.h to c:\msys\local\include.

 

      3.3.2.5. GSL

      ============

   Downloadsources:   ftp://ftp.gnu.org/gnu/gsl/gsl-1.9.tar.gz .Unpack to c:\msys\local\src .Run from MSYS console in the source directory:

  ./configure

  make

  make install

 

      3.3.2.6. EXPAT

      ==============

Download sources:  http://dfn.dl.sourceforge.net/sourceforge/expat/expat-2.0.0.tar.gz .Unpack to c:\msys\local\src .Run from MSYS console in the source directory:

  ./configure

  make

  make install

 

      3.3.2.7. POSTGRES

      =================

We're going to use precompiled binaries. Use the link belowfor download:

  http://wwwmaster.postgresql.org/download/mirrors-ftp?file=%2Fbinary%2Fv8.2.4%2Fwin32%2Fpostgresql-8.2.4-1-binaries-no-installer.zip

copy contents of pgsql directory from the archive to c:\msys\local

 

    3.3.3. Cleanup

    ==============

   We'redone with preparation of MSYS environment. Now you can delete all stuff inc:\msys\local\src - it takes quite a lotof space and it's not necessary at all.

 

源文档 <https://github.com/qgis/QGIS/blob/9745deae945657f5bbe4e410bc029ff6ffa5c0a7/INSTALL

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值