Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Linker Error Building GDAL

I am building GDAL from source using the MSVC 2015 64-bit command prompt. I am using Windows 8. Part way through the build, I get the following error:

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.

I have read on the Microsoft Site and GDAL Git issues section that this was a problem with the 2014 MSVC and pre-release version of MSVC 2015, but the issue was supposed to be resolved prior to the final release of MSVC 2015.

  • https://github.com/mapbox/windows-builds/issues/53
  • 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

I don't seem to be the only person with this issue, but I am also not seeing a solution (besides reverting to an older version of MSVC such as 2013). Has anybody had any luck getting GDAL to build using MSVC 2015 (64 bit)?

like image 563
rmkemker Avatar asked Oct 21 '15 18:10

rmkemker


1 Answers

GDAL-2.1.0 already has a similar change on nmake.opt

!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

but you must also specify the Visual Studio version from the command line with parameter MSVC_VER. e.g. for Visual Studio 2015 (MSVC_VER==1900) use this command line to compile

nmake -f makefile.vc MSVC_VER=1900
like image 98
escolano Avatar answered Sep 21 '22 00:09

escolano