rmkemker
rmkemker

Reputation: 470

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.

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)?

Upvotes: 6

Views: 4076

Answers (3)

escolano
escolano

Reputation: 101

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

Upvotes: 7

SteveEng
SteveEng

Reputation: 331

In addition to the above, I also had to make the following modification to the nmake.opt file:

the line that says

!IFNDEF MSVC_VER
#assume msvc VS2008.
MSVC_VER=1500
!ENDIF

Should be changed to:

!IFNDEF MSVC_VER
#assume msvc VS2015.
MSVC_VER=1900
!ENDIF

Upvotes: 0

Anders Larsolle
Anders Larsolle

Reputation: 76

I edited nmake.opt:

I replaced line 667 ... :

!IFDEF ODBC_SUPPORTED  
ODBCLIB = odbc32.lib odbccp32.lib user32.lib  
!ENDIF

with:

!IFDEF ODBC_SUPPORTED  
!IF $(MSVC_VER) < 1900  
ODBCLIB = odbc32.lib odbccp32.lib user32.lib  
!ELSE  
ODBCLIB = legacy_stdio_definitions.lib odbc32.lib odbccp32.lib user32.lib  
!ENDIF  
!ENDIF

/Anders

Upvotes: 6

Related Questions