C++ 链接器错误 LNK2038:在发布模式下检测到不匹配

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/4061929/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-28 14:26:33  来源:igfitidea点击:

Linker error LNK2038: mismatch detected in Release mode

c++visual-studio-2010linkerpcrerelease-mode

提问by Wartin

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

我正在尝试将我的一个小应用程序从 Win XP 和 VS 2005 移植到 Win 7 和 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?

我应该从哪里开始检查?

采纳答案by Alex Budovski

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.

您的应用程序正在以发布模式编译,但您正在链接 PCRE 的调试版本,该版本设置了 /MTd(或类似版本),从而导致 CRT 中的迭代器调试级别不匹配。

Recompile PCRE in release mode to match your own application.

在发布模式下重新编译 PCRE 以匹配您自己的应用程序。

The detect_mismatchpragmain VS 2010 is what causes this error to be emitted.

VS 2010 中的detect_mismatch编译指示是导致发出此错误的原因。

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

参见http://blogs.msdn.com/b/vcblog/archive/2009/06/23/stl-performance.aspx(搜索_ITERATOR_DEBUG_LEVEL)

回答by Thomas

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.

我有同样的错误。在我的情况下,解决方案很简单:我有一个项目 A 依赖于另一个项目 B。B 在调试模式下有一个预处理器定义 _DEBUG 而 A 没有。

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

只需将 _DEBUG 添加到项目 A(project->properties->c++->preprocessor->preprocessor definition) 就完成了。

回答by Art

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

这也可能是由于_HAS_ITERATOR_DEBUGGING=0在项目 B 中设置预处理器定义而不是在 A 中设置预处理器定义引起的,其中 A 生成 B 使用的库。

回答by Roman Bober

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

我的问题是依赖项目
在 Generl-->Character set 下使用了“使用多字节字符集” 。而其他项目具有“无设置”值