GDAL Linker Build Error

I am creating GDAL from the source using the 64-bit command line of MSVC 2015. I am using Windows 8. Partially through the assembly 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 read in the Microsoft Site and GDAL Git problems section that this is a problem with MSVC 2014 and the preliminary version of MSVC 2015, but the problem had to be resolved before the final version of MSVC 2015.

I seem to be not the only person with this problem, but I also don't see a solution (other than reverting to an older version of MSVC such as 2013). Is anyone really lucky with GDAL to build using MSVC 2015 (64 bit)?

+4
source share
3 answers

I edited nmake.opt:

I replaced the line 667 ...:

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

from:

!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

+5
source

GDAL-2.1.0 already has a similar change to 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 version of Visual Studio from the command line with the MSVC_VER parameter. for example for Visual Studio 2015 (MSVC_VER == 1900) use this command line to compile

nmake -f makefile.vc MSVC_VER=1900
+5
source

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

Must be changed to:

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

Source: https://habr.com/ru/post/1612629/


All Articles