ScummVM logo Forum Index - ScummVM website - Contact us - Buy Supported Games: GOG.com Rules - Search - Register - Login curved edge
Folder Forum Index > General Discussion > Building 1.9.0 with Visual Studio 2015 Linker Error and Fix
Building 1.9.0 with Visual Studio 2015 Linker Error and Fix
  Author    Thread Reply to topic
gwodus



Joined: 13 Oct 2017
Posts: 1
Building 1.9.0 with Visual Studio 2015 Linker Error and Fix 

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:

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



I had to add following option to the compiler options of the scummvm project:
code:
/D "CURL_STATICLIB"


And following options to the linker options:
code:
Iphlpapi.lib /NODEFAULTLIB: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.
 Reply with quote  
Post Fri Oct 13, 2017 10:44 am 
 View user's profile Send private message
Dark-Star



Joined: 30 Oct 2005
Posts: 129
Location: Reutlingen, GERMANY
Re: Building 1.9.0 with Visual Studio 2015 Linker Error and  

quote:
Originally posted by gwodus

/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
 Reply with quote  
Post Sun Oct 22, 2017 11:07 am 
 View user's profile Send private message
  Display posts from previous:      
Reply to topic

Forum Jump:
 



Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

 

Powered by phpBB © 2001, 2006 phpBB Group
Forum design by ScummVM team, icons by raina
curved edge   curved edge