C ++: how to find which standard library contains the missing external symbol?

I am building a project in VS2015 that uses third party libraries. The third party library I'm using needs to be VS2015 (x64) compatible, so it needs to be compatible with my project. My project settings also have "Ignore default libraries" which are set to NO.

Everything builds find except for a linker error, which I get right at the end, caused by a third party library:

LNK2001 unresolved external symbol "__declspec(dllimport) char const * __cdecl std::_Winerror_map(int)" (__imp_?_Winerror_map@std@@YAPEBDH@Z)

      

I have no idea what .lib this "_Winerror_map" function contains, but I was able to track down the location of the source code:

C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\crt\src\stl\sysError.cpp

      

I tried to just include this file in my project, but I get the following error:

Error   C2491   'std::_Winerror_map': definition of dllimport function not allowed

      

How can I determine which default lib this source file was included in?

+3


source to share


1 answer


When building on Windows, there are several different build options (e.g. dll vs static) and build types (debug vs release) and platforms (x86, x64).

This creates a number of complications for the compilation process that Microsoft tried to fix with pragma

 #if defined( _DEBUG )
 #   pragma comment ( lib, "steves_debug.lib") 
 #else
 #   pragma comment ( lib, "steves_release.lib" )
 #endif

      



comment (lib

describes the information that is added to .obj

to ensure that the correct libraries are correctly added to the link command.

This can be overridden by linking to /nodefaultlib

. This is a bad idea, as some of these options rely on code running before main

or dllMain

to ensure they are leaked.

During the compilation phase, MSVC dlls are usually unloaded using the / MT [d] / MD [d] distribution. MSDN: / MT / MD

0


source







All Articles