最近寫的項目需要在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 28LINK : error LNK2001: unresolved external symbol > > _GDALComputeMedianCutPCT at 32LINK : error LNK2001: unresolved external symbol _GDALReprojectImage at 48LINK : error LNK2001: unresolved external symbol _GDALSimpleImageWarp at 36LINK : error LNK2001: unresolved external symbol _OGRRegisterAllLINK : error LNK2001: unresolved external symbol _OGR_G_GetPointCountLINK : error LNK2001: unresolved external symbol _OPTGetProjectionMethodsLINK : error LNK2001: unresolved external symbol _OSRValidateLINK : 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