How to link external static libraries in debug mode

Hi all,

I have been not able to correctly link my static debug library to link correctly. Everything works fine in the release mode however.

In debug mode I get the following error :

Error	LNK2038	mismatch detected for '_ITERATOR_DEBUG_LEVEL': value '2' doesn't match value '0' in Engine.h.obj	
Error	LNK2038	mismatch detected for 'RuntimeLibrary': value 'MDd_DynamicDebug' doesn't match value 'MD_DynamicRelease' in Engine.h.obj	

I have created a Type.External Module to wrap my third party library and placed it in the source folder along with the game and the editor modules of my plugin.

I need this because I want to be able to step through the code of the external library after hitting a breakpoint in order to detect and fix issues.

However, I can’t, for the life of me, find a way so that I can step through the code in the external library in debug mode. Any and all help on this will be highly appreciated !

Best,
darkZ

1 Like

So after playing around with this for the whole day I have had some success by building a release library with debug information and optimizations disabled. But if there’s a correct way of linking actual Debug libraries I am still interested in hearing about possible solutions. Thanks !

Can you explain how you got it to work? I’m facing the same issue.

Got same issue long time ago. If I remember correctly, you have to rebuild your external library and change a setting in the Visual Studio’s project settings.
So open your library solution, access the project properties, go to C/C++ > Code Generation and find the line “Runtime Library”. Here you have the choice between :

  • Multi-threaded (/MT)
  • Multi-threaded Debug (/MTd)
  • Multi-threaded DLL (/MD)
  • Multi-threaded Debug DLL (/MDd)

“MDd_DynamicDebug” means “Multi-threaded Debug DLL (/MDd)” is used.
“MD_DynamicRelease” means “Multi-threaded DLL (/MD)” is used.

This setting should match the value in your error message. So you should use “Multi-threaded DLL (/MD)” when compiling your library (if I understood correctly).

More informations are provided here : c++ - LNK2038: mismatch detected for 'RuntimeLibrary': value 'MT_StaticRelease' doesn't match value 'MD_DynamicRelease' in file.obj - Stack Overflow and here : /MD, -MT, -LD (Use Run-Time Library) | Microsoft Docs

1 Like

Just found that you also have to make sure if you have _DEBUG defined it must be changed to _NDEBUG for /MD libs and vice-versa for /MDd libs or you will continue to get the link error.

2 Likes