GDAL编译Windows平台下64位的方式

    最近写的项目需要在64位的服务器上,结果32位下编译的不能用,只好重新编译一套64位的。在编译GDAL时,出现了连接错误,如下:

LINK : error LNK2001: unresolved external symbol > _OCTNewCoordinateTransformation at 8 
LINK : error LNK2001: unresolved external symbol _vbSafeArrayToPtr at 16 
LINK : error LNK2001: unresolved external symbol _GDALDitherRGB2PCT at 28
LINK : error LNK2001: unresolved external symbol > > _GDALComputeMedianCutPCT at 32
LINK : error LNK2001: unresolved external symbol _GDALReprojectImage at 48
LINK : error LNK2001: unresolved external symbol _GDALSimpleImageWarp at 36
LINK : error LNK2001: unresolved external symbol _OGRRegisterAll
LINK : error LNK2001: unresolved external symbol _OGR_G_GetPointCount
LINK : error LNK2001: unresolved external symbol _OPTGetProjectionMethods
LINK : error LNK2001: unresolved external symbol _OSRValidate
LINK : error LNK2001: unresolved external symbol _OGRFeatureStylePuller 

    按照GDAL论坛中的方式(http://www.osgeo.org/pipermail/gdal-dev/2006-May/008885.html)不是很清楚。

以下是我编译的步骤,哥研究了很长时间滴:

1:在GDAL目录下的nmake.opt文件中,找到SYM_PREFIX的定义,应该在438行左右

将SYM_PREFIX=_ 改为SYM_PREFIX= 就是将最后的下划线去掉

2:在GDAL目录下的makefile.vc文件中,找到46行左右的代码,如下:

BASE_INCLUDE = /INCLUDE:_GDALSimpleImageWarp@36 /

/INCLUDE:_GDALReprojectImage@48 /

/INCLUDE:_GDALComputeMedianCutPCT@32 /

/INCLUDE:_GDALDitherRGB2PCT@28 /

/INCLUDE:_OCTNewCoordinateTransformation@8 $(VB6_SAFEARRAYSYM)

修改为:

BASE_INCLUDE = /INCLUDE:$(SYM_PREFIX)GDALSimpleImageWarp /

/INCLUDE:$(SYM_PREFIX)GDALReprojectImage /

/INCLUDE:$(SYM_PREFIX)GDALComputeMedianCutPCT /

/INCLUDE:$(SYM_PREFIX)GDALDitherRGB2PCT /

/INCLUDE:$(SYM_PREFIX)OCTNewCoordinateTransformation $(VB6_SAFEARRAYSYM)

就是将后面的@开始,后面的数字删除。

现在开始编译吧,呵呵。祝你成功!

    PS:最新版的GDAL1.73版本直接可以在VS2008(VS2005也应该可以,没有测试)中选择x64编译,是直接可以编译过去的。前提是需要修改nmake.opt大概第一百行左右中的,Win64 = yes

转载自:https://blog.csdn.net/q_l_s/article/details/52468354

You may also like...