Windows10 + VS2015 環境下對gdal2.0.1進行64bit編譯小結


這是官方給出的編譯指導,但是在實踐過程中有幾點仍然需要特別注意。

Tip 1:不要使用默認的"VS開發人員命令提示"工具,使用該工具會遭遇如下的錯誤:

正在創建庫 gdal_i.lib 和對象 gdal_i.exp
INK : error LNK2001: 無法解析的外部符號 OGRFeatureStylePuller
INK : error LNK2001: 無法解析的外部符號 OSRValidate
INK : error LNK2001: 無法解析的外部符號 OPTGetProjectionMethods
INK : error LNK2001: 無法解析的外部符號 OGR_G_GetPointCount
INK : error LNK2001: 無法解析的外部符號 OGRRegisterAll
INK : error LNK2001: 無法解析的外部符號 GDALSimpleImageWarp
INK : error LNK2001: 無法解析的外部符號 GDALReprojectImage
INK : error LNK2001: 無法解析的外部符號 GDALComputeMedianCutPCT
INK : error LNK2001: 無法解析的外部符號 GDALDitherRGB2PCT
INK : error LNK2001: 無法解析的外部符號 OCTNewCoordinateTransformation

這是由於x64設置不當引起的,解決方法是使用VS2015 x64 本機命令提示符工具,如下:

這樣問題就可以迎刃而解。

Tip 2: 使用VS2015編譯會出現如下錯誤

Creating library gdal_i.lib and object gdal_i.exp

odbccp32.lib(dllload.obj) : error LNK2019: unresolved external symbol _vsnwprintf_s referenced in function StringCchPrintfW

gdal201.dll : fatal error LNK1120: 1 unresolved externals

NMAKE : fatal error U1077: '"C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\BIN\amd64\link.EXE"' : return code '0x460'

Stop.

解決方案:(感謝:http://blog.csdn.net/piaoyidage/article/details/50426434)

在gdal-2.0.1/make.opt中作如下修改:

把這段內容

!IFDEF ODBC_SUPPORTED

ODBCLIB = odbc32.lib odbccp32.lib user32.lib

!ENDIF

替換成:

!IFDEF ODBC_SUPPORTED

!IF $(MSVC_VER) >= 1900

# legacy_stdio_definitions.lib : https://connect.microsoft.com/VisualStudio/feedback/details/1134693/vs-2015-ctp-5-c-vsnwprintf-s-and-other-functions-are-not-exported-in-appcrt140-dll-breaking-linkage-of-static-libraries

ODBCLIB = legacy_stdio_definitions.lib odbc32.lib odbccp32.lib user32.lib

!ELSE

ODBCLIB = odbc32.lib odbccp32.lib user32.lib

!ENDIF

!ENDIF

為題得以解決。


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM