1.下载源码


geos-3.4.2.tar.bz2  http://trac.osgeo.org/geos/

proj-4.8.0.zip     http://trac.osgeo.org/proj/wiki/WikiStart#Download

启动VS2010 x64兼容命令提示符



2.首先编译GEOS,进入Geos目录后



1 autogen.bat
2 nmake /f makefile.vc


编译debug版本

nmake /f makefile.vc BUILD_DEBUG=YES


 

说明F:\gdal\geos-3.4.2文件夹下的makefile.vc

# This makefile.vc delegates making targets to src\makefile.vc

# so it's just a thin wrapper.


[GDAL]GEOS和Proj4编译_GDAL[GDAL]GEOS和Proj4编译_c++_02


1 #
2 # NMAKE Makefile to build GEOS on Windows
3 ###############################################################################
4 # This makefile.vc delegates making targets to src\makefile.vc
5 # so it's just a thin wrapper.
6 #
7 # Building on Win32 with Visual Studio
8 # ------------------------------------
9 #
10 # 1) Requires Visual C++ 2002 or later
11 # 2) Build running command "nmake /f makefile.vc" in top-level directory
12 #
13 # Produces:
14 # src\geos.dll: DLL - only exports the C API
15 # src\geos_i.lib: Stub library to link against for use of geos.dll.
16 # src\geos.lib: static library for use of C or C++ API.
17 ###############################################################################
18 GEOS_ROOT=.
19 !INCLUDE $(GEOS_ROOT)\nmake.opt
20
21 default: src_dir
22
23 src_dir:
24 cd src
25 $(MAKE) /f makefile.vc
26 cd ..
27
28 clean:
29 cd src
30 $(MAKE) /f makefile.vc clean
31 cd ..

View Code


3.接着编译Proj4



nmake /f makefile.vc install-all



4.最后编译GDAL


首先说明下我的文件目录F:\gdal文件夹下将gdal-1.10.0、geos-3.4.2和proj-4.8.0放在一起

[GDAL]GEOS和Proj4编译_GDAL_03

使用记事本或者其他的文本编辑器打开GDAL源代码目录下的nmake.opt文件,找到“# Uncomment for GEOS support”这句,大概在490行左右,将下面三行代码:

#GEOS_DIR=C:/warmerda/geos

#GEOS_CFLAGS =-I$(GEOS_DIR)/capi -I$(GEOS_DIR)/source/headers -DHAVE_GEOS

#GEOS_LIB     =$(GEOS_DIR)/source/geos_c_i.lib

修改为:

GEOS_DIR=F:\gdal\geos-3.4.2

GEOS_CFLAGS = -I$(GEOS_DIR)/capi -I$(GEOS_DIR)/include -DHAVE_GEOS

GEOS_LIB     = $(GEOS_DIR)/src/geos_c_i.lib

GEOS_DIR是geos-3.4.2编译后的文件夹路径:F:\gdal\geos-3.4.2。头文件主要在capi和include文件夹。

找到下面三行代码:

#PROJ_FLAGS =-DPROJ_STATIC

#PROJ_INCLUDE =-Id:\projects\proj.4\src

#PROJ_LIBRARY =d:\projects\proj.4\src\proj_i.lib

修改为:

#PROJ_FLAGS = -DPROJ_STATIC

PROJ_INCLUDE = -IF:\gdal\proj-4.8.0\src

PROJ_LIBRARY = F:\gdal\proj-4.8.0\src\proj_i.lib

不知道是不是我之前用中文路径的原因,开始编译时出了找不到geos_c.h的错误,然后我就改成现在的路径。