In VS2010, C++ project I get this error when linking in x64/Release:

error LNK2038: mismatch detected for '_ITERATOR_DEBUG_LEVEL': value '0' doesn't match value '1'

All other configuration/platform combinations link just fine. So a static library is built with _ITERATOR_DEBUG_LEVEL set to 0 and the .dll that depends on it somehow has _ITERATOR_DEBUG_LEVEL set to 1. I'm trying to figure out what that means so I can figure out how to turn it off!

The only references to this error that I found while Googling are when _ITERATOR_DEBUG_LEVEL's conflict with values of 0 and 2. That indicates an attempt to link release with debug. But I'm sure that's not the case here.

  • Linking release with debug library is the only way to get this error. Check it again. If you are sure, check it again, twice. – J-16 SDiZ Nov 9 '10 at 2:48
  • @J-16: apparently not ;-p – Steve Jessop Nov 9 '10 at 3:01
up vote 37 down vote accepted

Well, after struggling with this for an hour I figured it out right after I asked the question... for posterity:

_ITERATOR_DEBUG_LEVEL = 0 (in release mode)
_ITERATOR_DEBUG_LEVEL = 1 (in release mode if _SECURE_SCL is defined)
_ITERATOR_DEBUG_LEVEL = 2 (in debug mode)

Somehow I had _SECURE_SCL defined as a preprocessor definition only in the Release/x64 configuration of my DLL and I had to squint really hard to notice it. Once I removed that definition, the error went away.

Edit: I found this nice lecture/tutorial on msdn that (among other things) explains _ITERATOR_DEBUG_LEVEL. Unfortunately, it does require a fairly recent version of Microsoft Silverlight to watch.

  • Ran across this today which explains exactly what _ITERATOR_DEBUG_LEVEL is for and what its values are if you are curious: channel9.msdn.com/Shows/Going+Deep/… – Skrymsli Aug 4 '11 at 15:28
  • 1
    @Skyrmsli - I'm editing your comment into your answer. – Omnifarious Sep 14 '11 at 23:17

I ran into this problem on a release build, but I found that my preprocessor was defining _DEBUG when it should have been NDEBUG. Changing to NDEBUG fixed the problem.

For those with immaculate preprocessor definitions, yet still suffering from this error, check the project's runtime library setting.

If set to either one of the debug versions, _ITERATOR_DEBUG_LEVEL will get set to 2.

Your Answer

 

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.