[c++] error LNK2038: mismatch detected for '_ITERATOR_DEBUG_LEVEL': value '0' doesn't match value '2' in main.obj

I have read a lot of solutions to my problem but none helped. I tried clean, rebuild. Reinstalled visual 2010 and change from professional to ultimate. But still I dont know why I have this error. My project look like this: 1 Exe Solution to test my static library. 1 Dll Solution static library. Code which is converted to dll is using function from 1 lib called ClassificationFramework. I provided this lib as headers and cpp so basically source code. In Exe solution I linked my generated library + some other libs to run it + ClassificationFramework.dll. Everything works fine when I use Release but when I change to Debug (because I want to debug some stuff, I am tired of skipping debugger in release mode) I get this:

    2>Link:
    2>  ClassificationFramework.lib(SampleClass.obj) : MSIL .netmodule or module compiled with /GL found; restarting link with /LTCG; add /LTCG to the link command line to improve linker performance
    2>ClassificationFramework.lib(SampleClass.obj) : error LNK2038: mismatch detected for '_ITERATOR_DEBUG_LEVEL': value '0' doesn't match value '2' in main.obj
    2>ClassificationFramework.lib(SampleNamesSet.obj) : error LNK2038: mismatch detected for '_ITERATOR_DEBUG_LEVEL': value '0' doesn't match value '2' in main.obj
    2>ClassificationFramework.lib(SampleSet.obj) : error LNK2038: mismatch detected for '_ITERATOR_DEBUG_LEVEL': value '0' doesn't match value '2' in main.obj
    2>ClassificationFramework.lib(DirectoryReader.obj) : error LNK2038: mismatch detected for '_ITERATOR_DEBUG_LEVEL': value '0' doesn't match value '2' in main.obj
    2>LINK : warning LNK4098: defaultlib 'MSVCRT' conflicts with use of other libs; use /NODEFAULTLIB:library
    2>C:\Documents and Settings\Administrator\My Documents\Visual Studio 2010\Projects\Transformer\Debug\Tester.exe : fatal error LNK1319: 4 mismatches detected

When I build in Release I also got these warnings:

    1>Link:
    1>  Generating code
    1>c:\program files (x86)\microsoft visual studio 10.0\vc\include\utility(101): warning C4748: /GS can not protect parameters and local variables from local buffer overrun because ptimizations are disabled in function
    1>c:\users\kasia\documents\visual studio 2010\projects\classificationframework\classificationframework\directoryreader.cpp(30): warning C4748: /GS can not protect parameters and local variables from local buffer overrun because optimizations are disabled in function
    1>c:\program files (x86)\microsoft visual studio 10.0\vc\include\xstring(1589): warning C4748: /GS can not protect parameters and local variables from local buffer overrun because optimizations are disabled in function
    1>c:\users\kasia\documents\visual studio 2010\projects\classificationframework\classificationframework\samplenamesset.cpp(226): warning C4748: /GS can not protect parameters and local variables from local buffer overrun because optimizations are disabled in function
    1>c:\users\kasia\documents\visual studio 2010\projects\classificationframework\classificationframework\directoryreader.cpp(60): warning C4748: /GS can not protect parameters and local variables from local buffer overrun because optimizations are disabled in function
    1>c:\users\kasia\documents\visual studio 2010\projects\classificationframework\classificationframework\samplenamesset.cpp(199): warning C4748: /GS can not protect parameters and local variables from local buffer overrun because optimizations are disabled in function
    1>c:\users\kasia\documents\visual studio 2010\projects\classificationframework\classificationframework\sampleset.cpp(27): warning C4748: /GS can not protect parameters and local variables from local buffer overrun because optimizations are disabled in function
    1>c:\users\kasia\documents\visual studio 2010\projects\classificationframework\classificationframework\samplenamesset.cpp(59): warning C4748: /GS can not protect parameters and local variables from local buffer overrun because optimizations are disabled in function
    1>  Finished generating code
    1>ClassificationFramework.lib(SampleSet.obj) : warning LNK4099: PDB 'vc100.pdb' was not found with 'ClassificationFramework.lib(SampleSet.obj)' or at 'C:\Documents and Settings\Administrator\My Documents\Visual Studio 2010\Projects\Transformer\Release\vc100.pdb'; linking object as if no debug info
    1>ClassificationFramework.lib(SampleNamesSet.obj) : warning LNK4099: PDB 'vc100.pdb' was not found with 'ClassificationFramework.lib(SampleNamesSet.obj)' or at 'C:\Documents and Settings\Administrator\My Documents\Visual Studio 2010\Projects\Transformer\Release\vc100.pdb'; linking object as if no debug info
    1>ClassificationFramework.lib(SampleClass.obj) : warning LNK4099: PDB 'vc100.pdb' was not found with 'ClassificationFramework.lib(SampleClass.obj)' or at 'C:\Documents and Settings\Administrator\My Documents\Visual Studio 2010\Projects\Transformer\Release\vc100.pdb'; linking object as if no debug info
    1>ClassificationFramework.lib(DirectoryReader.obj) : warning LNK4099: PDB 'vc100.pdb' was not found with 'ClassificationFramework.lib(DirectoryReader.obj)' or at 'C:\Documents and Settings\Administrator\My Documents\Visual Studio 2010\Projects\Transformer\Release\vc100.pdb'; linking object as if no debug info
    1>  Tester.vcxproj -> C:\Documents and Settings\Administrator\My Documents\Visual Studio 2010\Projects\Transformer\Release\Tester.exe

I found that Debugger skips because of wrong path to pdb files.

'Tester.exe': Loaded 'C:\Documents and Settings\Administrator\My Documents\Visual Studio 2010\Projects\Work\Release\Tester.exe', Symbols loaded.
'Tester.exe': Loaded 'C:\WINDOWS\SysWOW64\kernel32.dll', Cannot find or open the PDB file
'Tester.exe': Unloaded 'C:\WINDOWS\SysWOW64\kernel32.dll'
'Tester.exe': Loaded 'C:\WINDOWS\SysWOW64\ntdll.dll', Cannot find or open the PDB file
'Tester.exe': Loaded 'C:\WINDOWS\SysWOW64\kernel32.dll', Cannot find or open the PDB file
'Tester.exe': Loaded 'C:\OpenCV2.2\bin\opencv_core220.dll', Binary was not built with debug information.
'Tester.exe': Loaded 'C:\WINDOWS\SysWOW64\msvcp100.dll', Symbols loaded.
'Tester.exe': Loaded 'C:\WINDOWS\SysWOW64\msvcr100.dll', Symbols loaded.
'Tester.exe': Loaded 'C:\OpenCV2.2\bin\opencv_highgui220.dll', Binary was not built with debug information.
'Tester.exe': Loaded 'C:\WINDOWS\SysWOW64\user32.dll', Cannot find or open the PDB file
'Tester.exe': Loaded 'C:\WINDOWS\SysWOW64\gdi32.dll', Cannot find or open the PDB file
'Tester.exe': Loaded 'C:\WINDOWS\SysWOW64\advapi32.dll', Cannot find or open the PDB file
'Tester.exe': Loaded 'C:\WINDOWS\SysWOW64\rpcrt4.dll', Cannot find or open the PDB file
'Tester.exe': Loaded 'C:\WINDOWS\SysWOW64\secur32.dll', Cannot find or open the PDB file
'Tester.exe': Loaded 'C:\WINDOWS\SysWOW64\ole32.dll', Cannot find or open the PDB file
'Tester.exe': Loaded 'C:\WINDOWS\SysWOW64\msvcrt.dll', Cannot find or open the PDB file
'Tester.exe': Loaded 'C:\WINDOWS\WinSxS\x86_Microsoft.Windows.Common-Controls_6595b64144ccf1df_5.82.3790.4770_x-ww_A689AB02\comctl32.dll', Cannot find or open the PDB file
'Tester.exe': Loaded 'C:\WINDOWS\SysWOW64\avifil32.dll', Cannot find or open the PDB file
'Tester.exe': Loaded 'C:\WINDOWS\SysWOW64\winmm.dll', Cannot find or open the PDB file
'Tester.exe': Loaded 'C:\WINDOWS\SysWOW64\msacm32.dll', Cannot find or open the PDB file
'Tester.exe': Loaded 'C:\WINDOWS\SysWOW64\msvfw32.dll', Cannot find or open the PDB file
'Tester.exe': Loaded 'C:\WINDOWS\SysWOW64\shell32.dll', Cannot find or open the PDB file
'Tester.exe': Loaded 'C:\WINDOWS\SysWOW64\shlwapi.dll', Cannot find or open the PDB file
'Tester.exe': Loaded 'C:\WINDOWS\SysWOW64\avicap32.dll', Cannot find or open the PDB file
'Tester.exe': Loaded 'C:\WINDOWS\SysWOW64\version.dll', Cannot find or open the PDB file
'Tester.exe': Loaded 'C:\OpenCV2.2\bin\opencv_imgproc220.dll', Binary was not built with debug information.
'Tester.exe': Loaded 'C:\WINDOWS\SysWOW64\imm32.dll', Cannot find or open the PDB file
'Tester.exe': Loaded 'C:\WINDOWS\SysWOW64\lpk.dll', Cannot find or open the PDB file
'Tester.exe': Loaded 'C:\WINDOWS\SysWOW64\usp10.dll', Cannot find or open the PDB file
'Tester.exe': Loaded 'C:\WINDOWS\WinSxS\wow64_Microsoft.Windows.Common-        Controls_6595b64144ccf1df_6.0.3790.4770_x-ww_8D2E3180\comctl32.dll', Cannot find or open the PDB file
The program '[4984] Tester.exe: Native' has exited with code 0 (0x0).

When i go to Debug->Windows->Modules i see that he cannot find those pdb files or something. How i can say him that those files are here here and here? I tried to run MSvisual as administrator but that too didnt help. I used microsoft server to load pdb files but also didnt help.

This question is related to c++ debugging linker

The answer is


I had a mismatch between projects: one with multi-byte character set, the other with Unicode. Correcting these to agree on Unicode corrected the problem.


I had similar problem, but the wrong setting was in the extern .lib file from which I did not have sources. If you do not have the source files, the simplest workaround is to just change the content of the .lib file.

Open the .lib file in an editor (I used PSPad, bud Windows notepad is also possible) and replace all occurences of _ITERATOR_DEBUG_LEVEL=2 to _ITERATOR_DEBUG_LEVEL=0


Last chance (if other ways don't work): define _ALLOW_ITERATOR_DEBUG_LEVEL_MISMATCH macro in all projects. It will disable "#pragma detect_mismatch" feature which is used in CRT headers.


I resolved my trouble in correcting the "Additional Library Directory", this one was wrong in indicating "$(SolutionDir)\Release", I changed it in "$(SolutionDir)\$(IntDir)"

To correct it, open your project properties -> Configuration Properties -> Linker -> General -> Additional Library Directory

I hope this will help some poeples with the same trouble ;)


If you would like to purposely link your project A in Release against another project B in Debug, say to keep the overall performance benefits of your application while debugging, then you will likely hit this error. You can fix this by temporarily modifying the preprocessor flags of project B to disable iterator debugging (and make it match project A):

In Project B's "Debug" properties, Configuration Properties -> C/C++ -> Preprocessor, add the following to Preprocessor Definitions:

_HAS_ITERATOR_DEBUGGING=0;_ITERATOR_DEBUG_LEVEL=0;

Rebuild project B in Debug, then build project A in Release and it should link correctly.


In VS2010 iterator debug level defaults to 2 in debug and is disabled in release. One of the dlls you are using probably has iterator debugging turned off in debug either because it was built in an older version of visual studio or they explicitly added the defines to the project.

Search for _ITERATOR_DEBUG_LEVEL and _SECURE_SCL remove them or set them appropriately in all projects and sources and rebuild everything.

_ITERATOR_DEBUG_LEVEL = 0 // disabled (for release builds)
_ITERATOR_DEBUG_LEVEL = 1 // enabled (if _SECURE_SCL is defined)
_ITERATOR_DEBUG_LEVEL = 2 // enabled (for debug builds)

In short you are probably mixing release and debug dlls. Don't linked release dlls in debug or vice versa!


The error can be caused by mixing together debug builds and release builds in same executable or dll.

  1. in the vs configuration manager, are some of your projects in debug mode and some in release mode?
  2. is one of your release projects has the preprocessor symbol DEBUG or _DEBUG defined?
  3. is one of your debug projects has the preprocessor symbol NDEBUG defined?

Like all the other answers, I checked my Configuration Properties -> C/C++ -> Preprocessor directives.
In my case I had the NDEBUG correctly defined in Release, but I also had: _SECURE_SCL=1.

Removing that one fixed the issue.


I had the same problem today (VS2010), I built Release | Win32, then tried to build Debug | Win32, and got this message.

I tried cleaning Debug | Win32 but the error still persisted. I then cleaned Release | Win32, then cleaned Debug | Win32, and then it built fine.


I had the same issue between debug and release libraries. The mistake was in the solution properties / Configurations properties / Configurations.

The projects configurations did not match the main configuration / platform.


In my case, for both Debug and Release, the solution was to clean then rebuild entire solution.

Edit: true in my case also (VS2017) step1: clean the project. step2: change configuration mode(from debug to release or vice versa). step3: clean the project. step4: build in the required configuration mode.

PS: to change config mode, find config settings under build menu


opencv_core245.lib(dxt.obj) : error LNK2038: mismatch detected for '_ITERATOR_DEBUG_LEVEL': value '0' doesn't match value '2' in test.obj I got error like this.
I have opencv_core245.lib and opencv_core245d.lib in Linker->Input->Additional dependenc. Since this two were confilicting I removed first one opencv_core245.lib. Error gone.


Try change _DEBUG to NDEBUG macro definition in C++ project properties (for Release configuration) Configuration Properties -> C/C++ -> Preprocessor -> Preprocessor Definitions


I managed to get rid of this error (in my case using Ogre3D + Bullet) by changing the dependency libraries to the debug versions in Project Properties -> Linker -> Input -> Additional Dependencies (VC10).

I changed BulletCollision.lib to BulletCollision_debug.lib (for debug configuration) and it compiled.


I make a little update on this issue, as I just had the same error today on an application which is linking against a static lib, after I migrated the old Visual 6 project to Visual Studio 2012.

In my case the error was that I mistakenly compiled the Release version of the static lib with /MDd instead of /MD, whereas the application is /MD in release. Setting the correct /MD in the static lib project solved the issue.

This is done in Project properties

  • Select Configuration Properties / C C++ / Code Generation in the tree
  • and the option Runtime Library set to the same on all your dependencies projects and application.

I had this problem as well.

My problem was that I had copy/pasted the library include directories from my debug configurations.

So project "Indep" was including static library "Dep.lib" from "../Debug", even in release. The fix was to change the library directory to "../Release" so I caught the release-built library rather than the previously-built debug library.


Small addition to the help above: I got the mismatch error after adding a static libto an older VST solution using VST 2017 . VST now generates "stdfax.h" for precompiled headers containing these 2 lines:

// Turn off iterator debugging as it makes the compiler very slow on large methods in debug builds
#define _HAS_ITERATOR_DEBUGGING 0

I also had this issue and it arose because I re-made the project and then forgot to re-link it by reference in a dependent project.

Thus it was linking by reference to the old project instead of the new one.

It is important to know that there is a bug in re-adding a previously linked project by reference. You've got to manually delete the reference in the vcxproj and only then can you re-add it. This is a known issue in Visual studio according to msdn.


In my case the NDEBUG macro definition in the "Preprocessor Definitions" needed to be changed to _DEBUG. I am building a static library for use in a .exe which was complaining about the very same error listed in the question. Go to Configuration Properties ("Project" menu, "Properties" menu item) and then click the C/C++, section, then the Preprocessor section under that, and then edit your Preprocessor Definitions so that NDEBUG is changed to _DEBUG (to match the setting in the exe).


Try this: Goto project property -> C/C++ -> Code generation -> Runtime Library Select from combobox value : Multi-threaded DLL (/MD) It work for me :)


Examples related to c++

Method Call Chaining; returning a pointer vs a reference? How can I tell if an algorithm is efficient? Difference between opening a file in binary vs text How can compare-and-swap be used for a wait-free mutual exclusion for any shared data structure? Install Qt on Ubuntu #include errors detected in vscode Cannot open include file: 'stdio.h' - Visual Studio Community 2017 - C++ Error How to fix the error "Windows SDK version 8.1" was not found? Visual Studio 2017 errors on standard headers How do I check if a Key is pressed on C++

Examples related to debugging

How do I enable logging for Spring Security? How to run or debug php on Visual Studio Code (VSCode) How do you debug React Native? How do I debug "Error: spawn ENOENT" on node.js? How can I inspect the file system of a failed `docker build`? Swift: print() vs println() vs NSLog() JavaScript console.log causes error: "Synchronous XMLHttpRequest on the main thread is deprecated..." How to debug Spring Boot application with Eclipse? Unfortunately MyApp has stopped. How can I solve this? 500 internal server error, how to debug

Examples related to linker

C compile : collect2: error: ld returned 1 exit status How to fix symbol lookup error: undefined symbol errors in a cluster environment gcc: undefined reference to libpthread.so.0: error adding symbols: DSO missing from command line Compilation fails with "relocation R_X86_64_32 against `.rodata.str1.8' can not be used when making a shared object" Multiple definition of ... linker error C Linking Error: undefined reference to 'main' ld cannot find -l<library> ldconfig error: is not a symbolic link Why am I getting "undefined reference to sqrt" error even though I include math.h header?