C++ Visual Studio 中的_ITERATOR_DEBUG_LEVEL 错误
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/4738987/
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
_ITERATOR_DEBUG_LEVEL error in visual studio
提问by KaiserJohaan
I am trying to compile JRTPLIB in Visual Studio 2010 on windows 7. It's been a true nightmare... but I'm atleast narrowing down the problems.
我正在尝试在 Windows 7 上的 Visual Studio 2010 中编译 JRTPLIB。这真是一场噩梦……但我至少在缩小问题的范围。
This is left.
这是剩下的。
Error 3 error LNK2038: mismatch detected for '_ITERATOR_DEBUG_LEVEL': value '2' doesn't match value '0' in client.obj C:\Users\Johan-bar\Documents\Visual Studio 2010\Projects\client\client\jrtplib.lib(rtpsession.obj) client
I googled a ton and the cause seems to be one is compiled in debug mode while the other is compiled in release mode.
我在谷歌上搜索了一吨,原因似乎是一个是在调试模式下编译的,而另一个是在发布模式下编译的。
I am aiming to compile a Release executable because I want to test on different computers.
我的目标是编译一个 Release 可执行文件,因为我想在不同的计算机上进行测试。
1) Which one is not in Release mode, JRTPLIB or client(mine, the one which is trying to compile)?
1) 哪一个不是 Release 模式,JRTPLIB 或客户端(我的,正在尝试编译的那个)?
2) How does one change the ITERATOR_DEBUG_LEVEL? Both are using Runtime Library /MT and preprocessor definitions WIN32, _MT, along with the defaults I guess.
2) 如何更改 ITERATOR_DEBUG_LEVEL?两者都使用运行时库 /MT 和预处理器定义 WIN32、_MT,以及我猜的默认值。
Cheers
干杯
采纳答案by ?? Tiib
Compile everything you use with -D_ITERATOR_DEBUG_LEVEL=0 option. It is so by default in VS 2010 Release mode, but some things are still built with other options and so are not binary compatible.
使用 -D_ITERATOR_DEBUG_LEVEL=0 选项编译您使用的所有内容。在 VS 2010 Release 模式下默认是这样,但有些东西仍然是用其他选项构建的,所以不是二进制兼容的。
In older visual studios there was _SECURE_SCL and i am not sure if some of code may still use it. Put somewhere (say into stdafx.h) a static check that these match.
在较旧的视觉工作室中,有 _SECURE_SCL,我不确定某些代码是否仍会使用它。在某处(比如在 stdafx.h 中)放置一个静态检查这些匹配。
#if _ITERATOR_DEBUG_LEVEL == 0 && _SECURE_SCL != 0
#error _SECURE_SCL != 0 when _ITERATOR_DEBUG_LEVEL == 0
#endif
If you want to see what value _ITERATOR_DEBUG_LEVEL has then you can use some #pragma message in code to tell you.
如果您想查看 _ITERATOR_DEBUG_LEVEL 有什么值,那么您可以在代码中使用一些 #pragma 消息来告诉您。
回答by RIK
The solution:
解决方案:
Project Pages >> Configuration Properties >> C,C++ >> Preprocessor >> Preprocessor Definitions
Add _ITERATOR_DEBUG_LEVEL=0
in there worked.
See also: How to set _ITERATOR_DEBUG_LEVEL in VS2010?
添加_ITERATOR_DEBUG_LEVEL=0
在那里工作。另请参阅:如何在 VS2010 中设置 _ITERATOR_DEBUG_LEVEL?
回答by Dale Wilson
I found another way to generate these errors.
我找到了另一种产生这些错误的方法。
I was using the Visual Studio 2010 batch build to build all possible combinations of platform and configuration and I was getting these errors. Looking at the output revealed that batch build was not honoring the project dependencies -- hence linking a stale library from the Release build witha freshly compiled Debug obj file.
我正在使用 Visual Studio 2010 批量构建来构建平台和配置的所有可能组合,但我收到了这些错误。查看输出结果表明,批处理构建不符合项目依赖关系——因此将发布构建中的陈旧库与新编译的调试 obj 文件链接起来。
Several lines later in the build output it built the Debug version of the library.
在构建输出的几行后面,它构建了库的调试版本。
Doing the "batch build" by hand (i.e. manually selecting the various combinations of platform and configuration) produced a clean build.
手动进行“批量构建”(即手动选择平台和配置的各种组合)产生了一个干净的构建。
Moral: Do not use Visual Studio 2010 batch build. I don't know if they've fixed this in later versions of VS.
道德:不要使用 Visual Studio 2010 批量构建。我不知道他们是否在 VS 的更高版本中修复了这个问题。