这是官方给出的编译指导,可是在实践过程当中有几点仍然须要特别注意。 app
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 spa
这是因为x64设置不当引发的,解决方法是使用VS2015 x64 本机命令提示符工具,以下: .net
这样问题就能够迎刃而解。 code
Tip 2: 使用VS2015编译会出现以下错误 orm
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 blog
gdal201.dll : fatal error LNK1120: 1 unresolved externals ip
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
为题得以解决。