利用VS2010编译GDAL-1.9.2
1. 解压gdal-1.9.2.tar.gz到C:\gdal-1.9.2
2. 修改安装配置文件存放的位置。 打开文件 C:\gdal-1.9.2\nmake.opt ,
(1) 在安装目录下新建文件夹 C:\gdal-1.9.2\build , 并修改 GDAL_HOME = "C:\gdal-1.9.2\build" 。
(2) 修改默认编译环境
# Check version of Visual C++ compiler:
# nmake -f makefile.vc MSVC_VER=xxxx
# where xxxx is one of following:
# 1700 = 11.0(2011)
# 1600 = 10.0(2010)
# 1500 = 9.0 (2008)
# 1400 = 8.0 (2005) - specific compilation flags, different from older VC++
# 1310 = 7.1 (2003)
# 1300 = 7.0 (2002)
# 1200 = 6.0
#
!IFNDEF MSVC_VER
#assume msvc VS2008.
MSVC_VER=1500
!ENDIF
# nmake -f makefile.vc MSVC_VER=xxxx
# where xxxx is one of following:
# 1700 = 11.0(2011)
# 1600 = 10.0(2010)
# 1500 = 9.0 (2008)
# 1400 = 8.0 (2005) - specific compilation flags, different from older VC++
# 1310 = 7.1 (2003)
# 1300 = 7.0 (2002)
# 1200 = 6.0
#
!IFNDEF MSVC_VER
#assume msvc VS2008.
MSVC_VER=1500
!ENDIF
上面源文件中表示默认用VS2008编译,即MSVC_VER=1500 ,
此处需要用VS2010编译,因此修改 MSVC_VER=1600 。
3. 编译源文件
以管理员身份运行cmd,在cmd中切换到VS2010的安装目录,执行 “cd C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\bin”,
执行 “vcvars32.bat”,
切换到GDAL目录,执行 “cd C:\gdal-1.9.2”,
执行 “nmake /f makefile.vc” ,
4. 安装文件
执行 "nmake /f makefile.vc install",执行完后,C:\gdal-1.9.2文件夹下增加了bin,data,及html文件夹。
执行 "nmake /f makefile.vc devinstall" , 执行完后,C:\gdal-1.9.2文件夹下增加了lib,include文件夹。
5. 安装完成以后需要在VS2010的项目中配置GDAL 。