LNK2038 mismatch detected for 'RuntimeLibrary'

My C++ engine is running into the following linker error when I include out/prefix/lib/aws-cpp-sdk-gamelift-server.lib

11>aws-cpp-sdk-gamelift-server.lib(GameLiftServerAPI.obj) : error LNK2038: mismatch detected for 'RuntimeLibrary': value 'MD_DynamicRelease' doesn't match value 'MT_StaticRelease' in App.obj
11>aws-cpp-sdk-gamelift-server.lib(GameLiftCommonState.obj) : error LNK2038: mismatch detected for 'RuntimeLibrary': value 'MD_DynamicRelease' doesn't match value 'MT_StaticRelease' in App.obj
11>aws-cpp-sdk-gamelift-server.lib(GameLiftServerState.obj) : error LNK2038: mismatch detected for 'RuntimeLibrary': value 'MD_DynamicRelease' doesn't match value 'MT_StaticRelease' in App.obj
11>aws-cpp-sdk-gamelift-server.lib(AuxProxyMessageSender.obj) : error LNK2038: mismatch detected for 'RuntimeLibrary': value 'MD_DynamicRelease' doesn't match value 'MT_StaticRelease' in App.obj
11>aws-cpp-sdk-gamelift-server.lib(Network.obj) : error LNK2038: mismatch detected for 'RuntimeLibrary': value 'MD_DynamicRelease' doesn't match value 'MT_StaticRelease' in App.obj
11>aws-cpp-sdk-gamelift-server.lib(sdk.pb.obj) : error LNK2038: mismatch detected for 'RuntimeLibrary': value 'MD_DynamicRelease' doesn't match value 'MT_StaticRelease' in App.obj
11>msvcprt.lib(MSVCP140.dll) : error LNK2005: "void __cdecl std::_Xbad_alloc(void)" (?_Xbad_alloc@std@@YAXXZ) already defined in libcpmt.lib(xthrow.obj)
11>msvcprt.lib(MSVCP140.dll) : error LNK2005: "void __cdecl std::_Xlength_error(char const *)" (?_Xlength_error@std@@YAXPEBD@Z) already defined in libcpmt.lib(xthrow.obj)
11>msvcprt.lib(MSVCP140.dll) : error LNK2005: "void __cdecl std::_Xout_of_range(char const *)" (?_Xout_of_range@std@@YAXPEBD@Z) already defined in libcpmt.lib(xthrow.obj)
11>msvcprt.lib(MSVCP140.dll) : error LNK2005: "void __cdecl std::_Xbad_function_call(void)" (?_Xbad_function_call@std@@YAXXZ) already defined in libcpmt.lib(xthrow.obj)

It seems aws-cpp-sdk-gamelft-server.lib was built as a dynamically linked lib with the /MD option, where I need a statically linked lib with the /MT option. I’m building with the following commands


cmake -G "Visual Studio 14 2015 Win64" -DBUILD_SHARED_LIBS=0 -DGAMELIFT_USE_STD=1 ..
msbuild ALL_BUILD.vcxproj /p:Configuration=Release

I’m also receiving some errors due to our project constraints on the use of non-std functions (eg. strcpy, strstr), which implies that -DGAMELIFT_USE_STD=1 didn’t actually work. I ran a grep -ir GAMELIFT_USE_STD . and couldn’t find it defined anywhere.

It seems like the build options are being ignored, so I tried manually building from the project. Opening out/ALL_BUILD.vcxproj and changing their Configuration Type from Utility to Static Library

And changing the aws-cpp-sdk-gamelift-server project runtime library from Multi-threaded DLL (/MD) to Multi-threaded (/MT)

Building, and then opening out/gamelift-server-sdk/ALL_BUILD.vcxproj and doing the same there. Then including out/gamelift-server-sdk/Release/aws-cpp-sdk-gamelift-server.lib I compile and run into these errors

11>aws-cpp-sdk-gamelift-server.lib(GameLiftServerState.obj) : error LNK2019: unresolved external symbol "public: __cdecl sio::client::client(void)" (??0client@sio@@QEAA@XZ) referenced in function "public: class Aws::GameLift::Outcome<void *,class Aws::GameLift::GameLiftError> __cdecl Aws::GameLift::Internal::GameLiftServerState::InitializeNetworking(void)" (?InitializeNetworking@GameLiftServerState@Internal@GameLift@Aws@@QEAA?AV?$Outcome@PEAXVGameLiftError@GameLift@Aws@@@34@XZ)
11>aws-cpp-sdk-gamelift-server.lib(AuxProxyMessageSender.obj) : error LNK2019: unresolved external symbol "public: class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > __cdecl google::protobuf::MessageLite::SerializePartialAsString(void)const " (?SerializePartialAsString@MessageLite@protobuf@google@@QEBA?AV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@XZ) referenced in function "private: class std::shared_ptr<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > > __cdecl Aws::GameLift::Internal::Network::AuxProxyMessageSender::ParseMessage(class google::protobuf::MessageLite *)" (?ParseMessage@AuxProxyMessageSender@Network@Internal@GameLift@Aws@@AEAA?AV?$shared_ptr@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@std@@PEAVMessageLite@protobuf@google@@@Z)
11>aws-cpp-sdk-gamelift-server.lib(AuxProxyMessageSender.obj) : error LNK2019: unresolved external symbol "public: void __cdecl sio::socket::emit(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &,class sio::message::list const &,class std::function<void __cdecl(class sio::message::list const &)> const &)" (?emit@socket@sio@@QEAAXAEBV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@AEBVlist@message@2@AEBV?$function@$A6AXAEBVlist@message@sio@@@Z@4@@Z) referenced in function "private: void __cdecl Aws::GameLift::Internal::Network::AuxProxyMessageSender::Send(class google::protobuf::MessageLite *,class std::function<void __cdecl(class sio::message::list const &)>)" (?Send@AuxProxyMessageSender@Network@Internal@GameLift@Aws@@AEAAXPEAVMessageLite@protobuf@google@@V?$function@$A6AXAEBVlist@message@sio@@@Z@std@@@Z)
11>aws-cpp-sdk-gamelift-server.lib(AuxProxyMessageSender.obj) : error LNK2019: unresolved external symbol "public: class std::shared_ptr<class sio::socket> const & __cdecl sio::client::socket(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &)" (?socket@client@sio@@QEAAAEBV?$shared_ptr@Vsocket@sio@@@std@@AEBV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@4@@Z) referenced in function "private: void __cdecl Aws::GameLift::Internal::Network::AuxProxyMessageSender::Send(class google::protobuf::MessageLite *,class std::function<void __cdecl(class sio::message::list const &)>)" (?Send@AuxProxyMessageSender@Network@Internal@GameLift@Aws@@AEAAXPEAVMessageLite@protobuf@google@@V?$function@$A6AXAEBVlist@message@sio@@@Z@std@@@Z)
11>aws-cpp-sdk-gamelift-server.lib(Network.obj) : error LNK2001: unresolved external symbol "public: class std::shared_ptr<class sio::socket> const & __cdecl sio::client::socket(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &)" (?socket@client@sio@@QEAAAEBV?$shared_ptr@Vsocket@sio@@@std@@AEBV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@4@@Z)
11>aws-cpp-sdk-gamelift-server.lib(AuxProxyMessageSender.obj) : error LNK2019: unresolved external symbol "private: void * __cdecl google::protobuf::Arena::AllocateAligned(class type_info const *,unsigned __int64)" (?AllocateAligned@Arena@protobuf@google@@AEAAPEAXPEBVtype_info@@_K@Z) referenced in function "public: static class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > * __cdecl google::protobuf::Arena::Create<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > >(class google::protobuf::Arena *)" (??$Create@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@Arena@protobuf@google@@SAPEAV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@PEAV012@@Z)
11>aws-cpp-sdk-gamelift-server.lib(sdk.pb.obj) : error LNK2001: unresolved external symbol "private: void * __cdecl google::protobuf::Arena::AllocateAligned(class type_info const *,unsigned __int64)" (?AllocateAligned@Arena@protobuf@google@@AEAAPEAXPEBVtype_info@@_K@Z)
11>aws-cpp-sdk-gamelift-server.lib(AuxProxyMessageSender.obj) : error LNK2019: unresolved external symbol "private: void __cdecl google::protobuf::Arena::AddListNode(void *,void (__cdecl*)(void *))" (?AddListNode@Arena@protobuf@google@@AEAAXPEAXP6AX0@Z@Z) referenced in function "public: static class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > * __cdecl google::protobuf::Arena::Create<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > >(class google::protobuf::Arena *)" (??$Create@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@Arena@protobuf@google@@SAPEAV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@PEAV012@@Z)
11>aws-cpp-sdk-gamelift-server.lib(sdk.pb.obj) : error LNK2001: unresolved external symbol "private: void __cdecl google::protobuf::Arena::AddListNode(void *,void (__cdecl*)(void *))" (?AddListNode@Arena@protobuf@google@@AEAAXPEAXP6AX0@Z@Z)
11>aws-cpp-sdk-gamelift-server.lib(AuxProxyMessageSender.obj) : error LNK2019: unresolved external symbol "protected: void __cdecl google::protobuf::internal::RepeatedPtrFieldBase::Reserve(int)" (?Reserve@RepeatedPtrFieldBase@internal@protobuf@google@@IEAAXH@Z) referenced in function "public: class Aws::GameLift::Outcome<void *,class Aws::GameLift::GameLiftError> __cdecl Aws::GameLift::Internal::Network::AuxProxyMessageSender::ProcessReady(int,class Aws::GameLift::Server::LogParameters const &)" (?ProcessReady@AuxProxyMessageSender@Network@Internal@GameLift@Aws@@QEAA?AV?$Outcome@PEAXVGameLiftError@GameLift@Aws@@@45@HAEBVLogParameters@Server@45@@Z)
11>aws-cpp-sdk-gamelift-server.lib(sdk.pb.obj) : error LNK2001: unresolved external symbol "protected: void __cdecl google::protobuf::internal::RepeatedPtrFieldBase::Reserve(int)" (?Reserve@RepeatedPtrFieldBase@internal@protobuf@google@@IEAAXH@Z)
11>aws-cpp-sdk-gamelift-server.lib(AuxProxyMessageSender.obj) : error LNK2019: unresolved external symbol "class google::protobuf::util::Status __cdecl google::protobuf::util::JsonStringToMessage(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &,class google::protobuf::Message *,struct google::protobuf::util::JsonParseOptions const &)" (?JsonStringToMessage@util@protobuf@google@@YA?AVStatus@123@AEBV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@PEAVMessage@23@AEBUJsonParseOptions@123@@Z) referenced in function "class google::protobuf::util::Status __cdecl google::protobuf::util::JsonStringToMessage(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &,class google::protobuf::Message *)" (?JsonStringToMessage@util@protobuf@google@@YA?AVStatus@123@AEBV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@PEAVMessage@23@@Z)
11>aws-cpp-sdk-gamelift-server.lib(Network.obj) : error LNK2001: unresolved external symbol "class google::protobuf::util::Status __cdecl google::protobuf::util::JsonStringToMessage(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &,class google::protobuf::Message *,struct google::protobuf::util::JsonParseOptions const &)" (?JsonStringToMessage@util@protobuf@google@@YA?AVStatus@123@AEBV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@PEAVMessage@23@AEBUJsonParseOptions@123@@Z)

Note: I had to copy the third party .lib’s from out/prefix/lib to out/gamelift-server-sdk/Release since these were not being generated when I built manually. It seems like the aws lib doesn’t recognize them though.

Any thoughts on the issues I’m running into? Thanks

Hi @glitchyme,

I’m sorry you are running into these issues.

I think you are simply missing two static libraries.
Where you included aws-cpp-sdk-gamelift-server.lib, try including sioclient.lib and libprotobuf.lib.
Sioclient.lib does have a dependency on libboost_date_time.lib, libboost_random.lib and libboost_system.lib so you might have to link against those three too.

Hope this helps!

Alexis

,
,

Thank you Alexis.

In the end I needed to link: aws-cpp-sdk-gamelift-server.lib, libprotobuf.lib, sioclient.lib, libboost_date_time.lib, libboost_random.lib, libboost_system.lib

Unfortunately I had to modify and compile each project individually in order to statically link the C Runtime Library. I suspect that what I’m looking for is the cmake option -DFORCE_SHARED_CRT=OFF like what’s offered in the aws sdk (cmake-force-shared-crt)

Protobuf
Project: thirdparty/protobuf-prefix/src/protobuf-build/protobuf.sln

  1. Change Configuration Type to Static library (.lib) (General)

  2. Change Runtime Library to Multi Threaded (/MT) (C/C++ -> Code Generation)
    Sioclient
    Project: thirdparty/sioclient-prefix/src/protobuf-build/protobuf.sln

  3. Change Configuration Type to Static library (.lib) (General)

  4. Change Runtime Library to Multi Threaded (/MT) (C/C++ -> Code Generation)
    Boost
    Directory: thirdparty/boost/

  5. Run bootstrap.bat

  6. Run b2.exe address-model=64 variant=release link=static threading=multi runtime-link=static