链接器错误 LNK2038:在发布模式下检测到不匹配
我正在尝试将我的一个小应用程序从 Win XP 和 VS 2005 移植到 Win 7 和 VS 2010。
该应用程序在调试模式下编译并顺利运行,但是在发布模式下我收到以下错误:
pcrecpp.lib(pcrecpp.obj) : error LNK2038: mismatch detected for
'_ITERATOR_DEBUG_LEVEL': value '0' doesn't match value '2' in LoginDlg.obj
我应该从哪里开始检查?
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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
您的应用程序正在发布模式下编译,但您正在链接到 PCRE 的调试版本,该版本设置了 /MTd (或类似的),从而导致 CRT 中的迭代器调试级别不匹配。
在发布模式下重新编译 PCRE 以匹配您自己的应用程序。
VS 2010 中的
detect_mismatch
pragma 是什么导致发出此错误。请参阅 http://blogs.msdn.com/ b/vcblog/archive/2009/06/23/stl-performance.aspx(搜索_ITERATOR_DEBUG_LEVEL)
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)
我有同样的错误。就我而言,解决方案很简单:我有一个项目 A 依赖于另一个项目 B。B 在调试模式下有一个预处理器定义 _DEBUG,而 A 没有。
只需将 _DEBUG 添加到项目 A(项目->属性->c++->预处理器->预处理器定义)即可完成。
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.
这也可能是由于在项目 B 中设置预处理器定义
_HAS_ITERATOR_DEBUGGING=0
而不是在 A 中设置的,其中 A 生成了 B 使用的库。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.我的问题是依赖项目使用“使用多字节字符集”
在常规-->字符集下。而其他项目具有“无设置”值
My problem was that dependent project used "Use Multi-Byte Character Set"
under Generl-->Character set. while other project had "No Set" value
就我而言,此错误是由缺少项目引用引起的。
据推测,添加冲突项目作为参考可以让构建系统确保构建正确的配置(调试/发布)。
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.