简体   繁体   中英

Linker error LNK2038: mismatch detected in Release mode

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?

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)

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.

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

这也可以通过在项目B中设置预处理器定义_HAS_ITERATOR_DEBUGGING=0而不是在A中生成由B使用的lib来实现。

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM