Building 1.9.0 with Visual Studio 2015 Linker Error and Fix

General chat related to ScummVM, adventure gaming, and so on.

Moderator: ScummVM Team

Post Reply
gwodus
Posts: 1
Joined: Fri Oct 13, 2017 9:34 am

Building 1.9.0 with Visual Studio 2015 Linker Error and Fix

Post by gwodus »

Hi.

A little note, if somebody stumbles upon the same problem. I am building on Windows 10 with Visual Studio 2015 (msvc14).

There was a small problem compiling scummvm-1.9.0 from source. At the very end there are a few linker errors:

Code: Select all

1>LINK : warning LNK4098: defaultlib 'MSVCRT' conflicts with use of other libs; use /NODEFAULTLIB:library
1>boxstorage.obj &#58; error LNK2019&#58; unresolved external symbol __imp__curl_slist_append referenced in function "public&#58; virtual class Networking&#58;&#58;Request * __thiscall Cloud&#58;&#58;Box&#58;&#58;BoxStorage&#58;&#58;streamFileById&#40;class Common&#58;&#58;String,class Common&#58;&#58;BaseCallback<struct Networking&#58;&#58;Response<class Networking&#58;&#58;NetworkReadStream *> > *,class Common&#58;&#58;BaseCallback<struct Networking&#58;&#58;ErrorResponse> *&#41;" &#40;?streamFileById@BoxStorage@Box@Cloud@@UAEPAVRequest@Networking@@VString@Common@@PAV?$BaseCallback@U?$Response@PAVNetworkReadStream@Networking@@@Networking@@@7@PAV?$BaseCallback@UErrorResponse@Networking@@@7@@Z&#41;
1>googledrivestorage.obj &#58; error LNK2001&#58; unresolved external symbol __imp__curl_slist_append
.
. A few more of the same kind
.
1>curlrequest.obj &#58; error LNK2001&#58; unresolved external symbol __imp__curl_slist_append
1>SDL_net.lib&#40;SDLnet.obj&#41; &#58; error LNK2019&#58; unresolved external symbol _GetAdaptersInfo@8 referenced in function _SDLNet_GetLocalAddresses
1>Debug32\scummvm.exe &#58; fatal error LNK1120&#58; 19 unresolved externals
I had to add following option to the compiler options of the scummvm project:

Code: Select all

/D "CURL_STATICLIB"
And following options to the linker options:

Code: Select all

Iphlpapi.lib /NODEFAULTLIB&#58;MSVCRT
Reasons:
  • libcurl.lib is a static lib, but CURL_STATICLIB was not defined, so the symbols where defined in dll fashion. Defining CURL_STATICLIB fixes this.
    For GetAdaptersInfo to be found I needed to add Iphlpapi.lib
    /NODEFAULTLIB:MSVCRT ist just to remove a linker warning.
And kudos to the developers. Bigger open source projects are sometimes a hastle to build for the first time. Thanks to the pre-compiled libraries it was pretty easy, besides that little hickup.

Regards.
User avatar
Dark-Star
Posts: 150
Joined: Sun Oct 30, 2005 9:36 pm
Location: Reutlingen, GERMANY

Re: Building 1.9.0 with Visual Studio 2015 Linker Error and

Post by Dark-Star »

gwodus wrote: /NODEFAULTLIB:MSVCRT ist just to remove a linker warning.
This can lead to quite hard-to-track-down errors later on. It usually means that one of the libraries you're importing (I think it's probably libcurl) was built against a specific runtime library. If you add this flag, the compiler can not check if the runtime you're building against is the same as the runtime that library was built against, it just forces both to the same one. If you have a function call that passes a runtime object (say, a file or something) between the main program and that library, and that object differs in both runtimes (e.g. in size), you will probably get a crash, or at least some unwanted behaviour.

The correct way to fix this is to rebuild the offending lib and make sure you're using the same runtime
Post Reply