QGIS 2014年7月18日版本
4. Building on Windows
4.1. Building with Microsoft Visual Studio
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.
4.1.1. Visual C++ Express Edition
The free (as in free beer) Express Edition installer is available under:
Currently we use Visual C++ 2008 Express for 32bit builds:
http://download.microsoft.com/download/d/c/3/dc3439e7-5533-4f4c-9ba0-8577685b6e7e/vcsetup.exe
And Visual C++ 2010 Express for 64bit builds:
http://download.microsoft.com/download/c/d/7/cd7d4dfb-5290-4cc7-9f85-ab9e3c9af796/vc_web.exe
You also need the Windows SDK for Windows 7 and .NET Framework 4:
http://download.microsoft.com/download/A/6/A/A6AC035D-DA3F-4F0C-ADA4-37C8E5D34E3D/winsdk_web.exe
4.1.2. Other tools and dependencies
Download and install following packages:
You can also use flex, bison & git from
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 OSGeo4W (select Advanced Installation):
- expat
- fcgi
- gdal
- grass
- gsl-devel
- iconv
- pyqt4
- qt4-devel
- qwt5-devel-qt4
- sip
- spatialite
- libspatialindex-devel
- python-qscintilla
This will also select packages the above packages depend on.
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.
4.1.3. Setting up the Visual Studio project with CMake
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):
@echo off
path %SYSTEMROOT%\system32;%SYSTEMROOT%;%SYSTEMROOT%\System32\Wbem;%PROGRAMFILES%\CMake 2.8\bin;%PROGRAMFILES%\subversion\bin;%PROGRAMFILES%\GnuWin32\bin
set PYTHONPATH= set VS90COMNTOOLS=%PROGRAMFILES%\Microsoft Visual Studio 9.0\Common7\Tools\
call "%PROGRAMFILES%\Microsoft Visual Studio 9.0\VC\vcvarsall.bat" x86 set INCLUDE=%INCLUDE%;%PROGRAMFILES%\Microsoft Platform SDK for Windows Server 2003 R2\include
set LIB=%LIB%;%PROGRAMFILES%\Microsoft Platform SDK for Windows Server 2003 R2\lib set OSGEO4W_ROOT=C:\OSGeo4W
call "%OSGEO4W_ROOT%\bin\o4w_env.bat" @set GRASS_PREFIX=c:/OSGeo4W/apps/grass/grass-6.4.0
@set INCLUDE=%INCLUDE%;%OSGEO4W_ROOT%\include
@set LIB=%LIB%;%OSGEO4W_ROOT%\lib;%OSGEO4W_ROOT%\lib @cmd
Start the batch file and on the command prompt checkout the QGIS source from git 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 output will be generated.
Now run cmake-gui
(still from cmd
) and in the Where is the source code: box, browse to the top level QGIS directory.
In the Where to build the binaries: box, browse to the 'build' directory you created.
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:\``).
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.
Hit Configure
to start the configuration and select Visual Studio 9 2008
and keep native compilers
and click Finish
.
The configuration should complete without any further questions and allow you to click 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.
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).
After the build completed you should install QGIS using the INSTALL target.
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
4.2. Building using MinGW
Note: This section might be outdated as nowadays Visual C++ is use to build the "official" packages.
Note: For a detailed account of building all the dependencies yourself you can visit Marco Pasetti's website here:
http://www.webalice.it/marco.pasetti/qgis+grass/BuildFromSource.html
Read on to use the simplified approach with pre-built libraries...
4.2.1. MSYS
MSYS provides a unix style build environment under windows. We have created a zip archive that contains just about all dependencies.
Get this:
http://download.osgeo.org/qgis/win32/msys.zip
and unpack to c:\msys
If you wish to prepare your msys environment yourself rather than using our pre-made one, detailed instructions are provided elsewhere in this document.
4.2.2. Qt
Download Qt opensource precompiled edition exe and install (including the download and install of mingw) from here:
http://qt.nokia.com/downloads/
When the installer will ask for MinGW, you don't need to download and install it, just point the installer to c:\msys\mingw
When Qt installation is complete:
Edit C:\Qt\4.7.0\bin\qtvars.bat and add the following lines:
set PATH=%PATH%;C:\msys\local\bin;c:\msys\local\lib
set PATH=%PATH%;"C:\Program Files\Subversion\bin"
I suggest you also add C:\Qt\4.7.0\bin\ to your Environment Variables Path in the windows system preferences.
If you plan to do some debugging, you'll need to compile debug version of Qt: C:\Qt\4.7.0\bin\qtvars.bat compile_debug
Note: there is a problem when compiling debug version of Qt 4.7, the script ends with this message "mingw32-make: *** No rule to make target `debug'. Stop.". To compile the debug version you have to go out of src directory and execute the following command:
c:\Qt\4.7.0 make
4.2.3. Flex and Bison
Get Flex http://sourceforge.net/project/showfiles.php?group_id=23617&package_id=16424 (the zip bin) and extract it into c:\msys\mingw\bin
4.2.4. Python stuff (optional)
Follow this section in case you would like to use Python bindings for QGIS. To be able to compile bindings, you need to compile SIP and PyQt4 from sources as their installer doesn't include some development files which are necessary.
4.2.4.1. Download and install Python - use Windows installer
(It doesn't matter to what folder you'll install it)
4.2.4.2. Download SIP and PyQt4 sources
http://www.riverbankcomputing.com/software/sip/download http://www.riverbankcomputing.com/software/pyqt/download
Extract each of the above zip files in a temporary directory. Make sure to get versions that match your current Qt installed version.
4.2.4.3. Compile SIP
c:\Qt\4.7.0\bin\qtvars.bat
python configure.py -p win32-g++
make
make install
4.2.4.4. Compile PyQt
c:\Qt\4.7.0\bin\qtvars.bat
python configure.py
make
make install
4.2.4.5. Final python notes
/!\ You can delete the directories with unpacked SIP and PyQt4 sources after a successfull install, they're not needed anymore.
4.2.5. git
In order 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
4.2.6. CMake
CMake is build system used by QGIS. Download it from here:
http://www.cmake.org/files/v2.8/cmake-2.8.2-win32-x86.exe
4.2.7. QGIS
Start a cmd.exe window ( Start -> Run -> cmd.exe ) Create development directory and move into it
md c:\dev\cpp
cd c:\dev\cpp
Check out sources from GIT:
git clone git://github.com/qgis/QGIS.git
4.2.8. Compiling
As a background read the generic building with CMake notes at the end of this document.
Start a cmd.exe window ( Start -> Run -> cmd.exe ) if you don't have one already. Add paths to compiler and our MSYS environment:
c:\Qt\4.7.0\bin\qtvars.bat
For ease of use add c:\Qt\4.7.0\bin\ to your system path in system properties so you can just type qtvars.bat when you open the cmd console. Create build directory and set it as current directory:
cd c:\dev\cpp\qgis
md build
cd build
4.2.9. Configuration
cmakesetup ..
Note: You must include the '..' above.
Click 'Configure' button. When asked, you should choose 'MinGW Makefiles' as generator.
There's a problem with MinGW Makefiles on Win2K. If you're compiling on this platform, use 'MSYS Makefiles' generator instead.
All dependencies should be picked up automatically, if you have set up the Paths correctly. The only thing you need to change is the installation destination (CMAKE_INSTALL_PREFIX) and/or set 'Debug'.
For compatibility with NSIS packaging scripts I recommend to leave the install prefix to its default c:\program files\
When configuration is done, click 'OK' to exit the setup utility.
4.2.10. Compilation and installation
make make install
4.2.11. Run qgis.exe from the directory where it's installed (CMAKE_INSTALL_PREFIX)
Make sure to copy all .dll:s needed to the same directory as the qgis.exe binary is installed to, if not already done so, otherwise QGIS will complain about missing libraries when started.
A possibility is to run qgis.exe when your path contains c:\msys\local\bin and c:\msys\local\lib directories, so the DLLs will be used from that place.
4.2.12. Create the installation package: (optional)
Download and install NSIS from (http://nsis.sourceforge.net/Main_Page)
Now using windows explorer, enter the win_build directory in your QGIS source tree. Read the READMEfile there and follow the instructions. Next right click on qgis.nsi and choose the option 'Compile NSIS Script'.
4.3. Creation of MSYS environment for compilation of QGIS
4.3.1. Initial setup
4.3.1.1. MSYS
This is the environment that supplies many utilities from UNIX world in Windows and is needed by many dependencies to be able to compile.
Download from here:
http://puzzle.dl.sourceforge.net/sourceforge/mingw/MSYS-1.0.11-2004.04.30-1.exe
Install to c:\msys
All stuff we're going to compile is going to get to this directory (resp. its subdirs).
4.3.1.2. MinGW
Download from here:
http://puzzle.dl.sourceforge.net/sourceforge/mingw/MinGW-5.1.3.exe
Install to c:\msys\mingw
It suffices to download and install only g++
and mingw-make
components.
4.3.1.3. Flex and Bison
Flex and Bison are tools for generation of parsers, they're needed for GRASS and also QGIS compilation.
Download the following packages:
Unpack them all to c:\msys\local
4.3.2. Installing dependencies
4.3.2.1. Getting ready
Paul Kelly did a great job and prepared a package 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 to compile it (for those interested):
Unpack the whole package to c:\msys\local
4.3.2.2. GRASS
Grab sources from CVS or use a weekly snapshot, see:
In MSYS console go to the directory where you've unpacked or checked out sources (e.g. c:\msys\local\src\grass-6.3.cvs
)
Run these commands:
export PATH="/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:
4.3.2.3. GEOS
Download the sources:
Unpack to e.g. c:\msys\local\src
To compile, I had to patch the sources: in file source/headers/timeval.h
line 13. Change it from:
#ifdef _WIN32
to:
#if defined(_WIN32) && defined(_MSC_VER)
Now, in MSYS console, go to the source directory and run:
./configure --prefix=/usr/local
make
make install
4.3.2.4. SQLITE
You can use precompiled DLL, no need to compile from source:
Download this archive:
and copy sqlite3.dll from it to c:\msys\local\lib
Then download this archive:
and copy sqlite3.h to c:\msys\local\include
4.3.2.5. GSL
Download sources:
Unpack to c:\msys\local\src
Run from MSYS console in the source directory:
./configure
make
make install
4.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
4.3.2.7. POSTGRES
We're going to use precompiled binaries. Use the link below for download:
copy contents of pgsql directory from the archive to c:\msys\local
4.3.3. Cleanup
We're done with preparation of MSYS environment. Now you can delete all stuff in c:\msys\local\src
- it takes quite a lot of space and it's not necessary at all.
QGIS 2014年7月18日版本的更多相关文章
- Uploadify 笔记分享 -- 2014年10月18日
最近要做一个项目,有个部分需要用到Uploadify,以前用过,但不是很懂,找了无数遍的中文文档,发现好多都是以前的,都不能用,一时间索性自己写了个笔记,随用随查 <form> <i ...
- SE 2014年4月18日
实验需求: R1 R2 R3用环回口建立IBGP对等体(使用对等体组),AS号为100 R4 R5 R6用环回口建立IBGP对等体(使用对等体组),AS号为 ...
- 09.13日记(2014年9月13日00:18:26)英语,bootstrap,阮一峰,
我们这里只推荐一本语法书:台湾的旋元佑老师写的<文法俱乐部>(简体版名为<语法俱乐部>).这本书因为出版社倒闭而绝版,淘宝可以买到影印的版本. (1)学英语:奶爸的英语教室 资 ...
- SQLSERVER2014 2014年4月1日发布
SQLSERVER2014 2014年4月1日发布 原文地址: http://blogs.technet.com/b/microsoft_blog/archive/2014/03/18/sql-ser ...
- 千寻浏览器 1.0 Beta 1(524)(2014年5月27日)
千寻浏览器--又一款新生浏览器今天进入各位浏览迷的视野.千寻浏览器基于IE内核,据传是由百度浏览器的上海团队操刀,在功能定位上,与目前的QQ浏览器有些相似. 千寻来自官方的解释:寻,追寻,探索,又是古 ...
- iPad mini Retina越狱小结【2014年02月06日 - 初稿】
Update History 2014年02月06日 - 初稿 0.引言 本来一直都没有苹果的产品除了第一代的iPod(没怎么使用最后大学送人了 @李清纯(255270520) ,巧合的是老妈学校发了 ...
- 亚马逊6月18日发布惊世之作 或为3D智能手机
亚马逊将在 6 月 18 日举行一个产品发布会. 其内容可能是关于传闻已久的亚马逊智能手机.该公司在 YouTube 上公布了一段炫耀这款设备的视频.这段视频展示了很多人在这款产品前摇头晃脑,并且表现 ...
- CSDN下载频道于2014年7月17日改版,23日-24日系统维护
尊敬的用户你们好: CSDN于2005年推出了下载服务,经过数年的发展,下载频道的用户已经为无数用户提供了帮助.分享500万的技术资源. 感谢用户们的资源共享精神,以及对CSDN下载频道的支持 下载频 ...
- 终端、mac等小技巧——2019年10月18日
1.新建finder窗口 cmd+N 2.查看文件夹结构 brew install tree tree命令行参数(只实用与安装了tree命令行工具): -a 显示所有文件和目录. -A 使用ASNI绘 ...
随机推荐
- c语言使用librdkafka库实现kafka的生产和消费实例(转)
关于librdkafka库的介绍,可以参考kafka的c/c++高性能客户端librdkafka简介,本文使用librdkafka库来进行kafka的简单的生产.消费 一.producer librd ...
- linux多路径配置
一.什么是多路径 普通的电脑主机都是一个硬盘挂接到一个总线上,这里是一对一的关系.而到了有光纤组成的SAN环境,或者由iSCSI组成的IPSAN环境,由于主机和存储通过了光纤交换机或者多块网卡及IP来 ...
- TCP/IP知识总结(TCP/IP协议族读书笔记二)
接下来,总结一下网络层的协议,IP,ARP,RARP,ICMP,IGMP.当我们在网络传输的过程中,把分组交付到主机或路由器需要两级地址:物理地址和逻辑地址.而且我们需要能够把物理地址映射成为相应的逻 ...
- 启动startUML的时候报错“"Exception EOleSysError in module StarUML.exe at 000AD559. "
win7操作系统在安装startuml的时候总是报错 出现了如下错误提示:"Exception EOleSysError in module StarUML.exe at 000AD559. ...
- css中选择器
css中常用的选择器有: 1.元素选择器:h1{} 如<h1></h1> 2.类选择器:.test{}或者h1.test{} 如<h1 class="test ...
- hivepython 实现一行转多行
案例1: ==效果等同于一行转多行 数据表名称:zhangb.gid_tags 数据格式,每行是2个字段,(gid,tags) ,可能有脏数据,分隔符为“\t”, ANDROID-9de77225 ...
- azkaban编译安装配置文档
azkaban编译安装配置文档 参考官方文档: http://azkaban.github.io/azkaban/docs/latest/ azkaban的配置文件说明:http://azkaban. ...
- JAVA知识积累 JSP第一篇【JSP介绍、工作原理、生命周期、语法、指令、行为】
什么是JSP JSP全名为Java Server Pages,java服务器页面.JSP是一种基于文本的程序,其特点就是HTML和Java代码共同存在! 为什么需要JSP JSP是为了简化Servle ...
- win7安装SQL2005出现29506错误
解决方法: 假设下载的文件名为SQLServer2005_SSMSEE.msi ,并且放在F盘根目录下, 新建一个文本文件,输入msiexec /i F:\SQLServer2005_SSMSEE.m ...
- SQL2000清除SQL日志
1.打开查询分析器,输入命令DUMP TRANSACTION 数据库名 WITH NO_LOG2.再打开企业管理器--右键你要压缩的数据库--所有任务--收缩数据库--收缩文件--选择日志文件--在收 ...