43

I am trying to port a small app of mine from Win XP and VS 2005 to Win 7 and VS 2010.

The app compiles and runs smoothly in Debug mode, however in Release mode I get the following error:

pcrecpp.lib(pcrecpp.obj) : error LNK2038: mismatch detected for 
'_ITERATOR_DEBUG_LEVEL': value '0' doesn't match value '2' in LoginDlg.obj

Where should I start checking?

Cœur
  • 37,241
  • 25
  • 195
  • 267
Wartin
  • 1,965
  • 5
  • 25
  • 40

5 Answers5

40

Your app is being compiled in release mode, but you're linking against the debug version of PCRE, which had /MTd (or similar) set, thus causing the mismatch in iterator debugging level in the CRT.

Recompile PCRE in release mode to match your own application.

The detect_mismatch pragma in VS 2010 is what causes this error to be emitted.

See http://blogs.msdn.com/b/vcblog/archive/2009/06/23/stl-performance.aspx (search for _ITERATOR_DEBUG_LEVEL)

Alex Budovski
  • 17,947
  • 6
  • 53
  • 58
25

I had the same error. In my case the solution is easy: I had one project A depending on another project B. B had a preprocessor definition _DEBUG in debug mode and A didn't.

Just add _DEBUG to project A(project->properties->c++->preprocessor->preprocessor definitions) and you're done.

Thomas
  • 251
  • 3
  • 2
  • 4
    Thank you! Or in release mode you might have `NDEBUG` defined in one and not the other. – Derek Sep 04 '12 at 14:15
6

This can also be caused by setting the preprocessor definition _HAS_ITERATOR_DEBUGGING=0 in project B and not in A where A produces a lib used by B.

Quonux
  • 2,975
  • 1
  • 24
  • 32
Art
  • 61
  • 1
  • 1
  • What if the problematic lib is a 3rd party software? – Tomáš Zato Oct 10 '18 at 13:58
  • @TomášZato Then either compile with the same options or request them to compile one for you. At work, I have made request to compile just for us and the 3rd party did it. – qqqqq May 07 '23 at 18:32
4

My problem was that dependent project used "Use Multi-Byte Character Set"
under Generl-->Character set. while other project had "No Set" value

0

In my case this error was caused by a missing project reference.

Presumably adding the conflicting project as a reference allowed the build system to make sure that the correct configuration (debug/release) was built.

Iizuki
  • 354
  • 1
  • 6
  • 12