1

I have been facing this error in my project. The project has many sub projects and the sub projects are deployed as Static library.

I had this error before but configuring runtime library as same for all the static library and the .exe would help me to get rid of it. Most of the errors are gone but one of the static library throw this error even when the config is same for all the projects.

The error says

Error   LNK2038 mismatch detected for 'RuntimeLibrary': value 'MD_DynamicRelease' doesn't match value 'MTd_StaticDebug' in application.obj  flRenderServer  D:\Projects\FLProject\RenderBox\singlegame_renderbox\Production\FantasticLeague\_Code\FLeague\flRenderServer\miniEngine.lib(miniEngine.obj) 1   

this is similar

Severity    Code    Description Project File    Line    Suppression State
Error   LNK2038 mismatch detected for '_ITERATOR_DEBUG_LEVEL': value '0' doesn't match value '2' in application.obj flRenderServer  D:\Projects\FLProject\RenderBox\singlegame_renderbox\Production\FantasticLeague\_Code\FLeague\flRenderServer\miniEngine.lib(miniEngine.obj) 1   

No other library give any error except this. Any help would be appreciated, thanks :)

Skiggz
  • 49
  • 1
  • 4

1 Answers1

6

This usually happens if your static library and the executable itself are compiled with different configurations. In your case miniEngine seems to be compiled in debug configuration and your executable in release configuration. Sometimes the iterator debug level is directly set by #define _ITERATOR_DEBUG_LEVEL ... or by a preprocessor definition in the project properties. The value of RuntimeLibrary is influenced by the compiler flags /MD[d] and /MT[d].

Details: The Linker issues error LINK2038 if the object files contain a linker directive /FAILIFMISMATCH:<Name>=<Value> and the <Value> for some <Name> mismatches between the linked object files. You can list the linker directives of an object file with dumpbin /DIRECTIVES <object-file>. These directives are usually set by an #pragma detect_mismatch("<Name>", "<Value>") line in some header file. The value depends on the specific configuration the object file was build with. These directives try to ensure you don't link incompatible object files together. An object file compiled in debug mode might for example expect a different class layout for some standard classes like iterators.

Possible causes:

  • Manually defined #define _ITERATOR_DEBUG_LEVEL in one source file of the static library but not in any source file of the executable, or vice versa
  • Executable links to the debug version of the static library: The values in "Additional Dependencies" and "Additional Library Directories" in the linker properties in the project properties lead the linker to the debug version of the static library. This works as long as the executable is build in the debug configuration but magically breaks if build in release configuration.
  • The values of "Runtime Library" in "code generation properties" in "C/C++ properties" in the project properties of the executable or the static library was manually set a different mismatching value.

Please double check the paths and configurations of linked static library and executable.

phlipsy
  • 2,899
  • 1
  • 21
  • 37
  • I believe they both are in the same config :/ – Skiggz Aug 25 '20 at 06:05
  • 1
    it is solved. I have multiple sln files for all the projects. So while building individually miniEngine creates a lib file inside it's own debug folder and that folder was linked along with the directory where all the lib files exist. So multiple linking was causing this error – Skiggz Aug 25 '20 at 09:35