VS2010 未修复BUG:'_ITERATOR_DEBUG_LEVEL': value '2'

简介:

Static Library Dependencies in Visual Studio 2010

I've been porting my Visual Studio 2008 C++ application to Visual Studio 2010. One rough spot I've hit is the change in how static library dependencies works. In VS2005 and VS2008, we completely gave up on automated static library dependencies because they only worked in the IDE, not from automated builds with VCBUILD. VS2010 was supposed to fix this problem. (Note that MSBUILD replaces VCBUILD for command line builds in VS2010.)

The problem manifested itself during Batch Build with errors indicating that Debug libraries were being linked into Release builds. For example, these errors happen if you are using STL:

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

MSVCRTD.lib(MSVCR100D.dll) : error LNK2005: _strcspn already defined in libcmt.lib(strcspn.obj)

I've also seen these errors for vanilla MFC projects:

msvcrtd.lib(ti_inst.obj) : error LNK2005: "private: __thiscall type_info::type_info(class type_info const &)" (??0type_info@@AAE@ABV0@@Z) already defined in libcmt.lib(typinfo.obj)

msvcrtd.lib(ti_inst.obj) : error LNK2005: "private: class type_info & __thiscall type_info::operator=(class type_info const &)" (??4type_info@@AAEAAV0@ABV0@@Z) already defined in libcmt.lib(typinfo.obj)

Visual Studio 2010 has multiple ways of specifying dependencies.  The actual effect of each setting and settings' interdependence does not appear to be officially documented, although there is some information at http://msdnrss.thecoderblogs.com/2010/02/16/project-settings-changes-with-vs2010/ and at http://blogs.msdn.com/vcblog/archive/2010/03/02/visual-studio-2010-c-project-upgrade-guide.aspx.

The first way of specifying dependencies continues from previous versions of Visual Studio in Project | Project Dependencies. However, unlike earlier versions of Visual Studio, this only affects project build order, not dependency library linking. Also, this only affects project build order in the IDE. It does not affect project build order in MSBUILD. Therefore, you need to configure that page, but it's useless for command line builds. Changes on this page are reflected in the .sln file.

The real action is now on the Framework and References tab in the project properties. This tab used to be exclusively for .Net dependencies, but now it's been expanded for C++ dependencies. When I looked at this page for my project, it looked like this:

 


There are a couple of things to notice. First, the Configuration in the top left is grayed out. The Debug/Release settings do not apply to the Framework and References page. Second, you'll notice that the Full Path in the properties on the right points to the Debug build. In other words, the Debug library is always linked, even in the Release build. I've blogged about this problem in the past with .Net libraries, but this is pretty fundamental for C++ libraries.

I first thought that the solution was to set Reference Assembly Output to False. However, after reading the blog of one of the Microsoft Program Managers and following up with him, he said that the Reference Assembly Output option is only for managed libraries and does not do anything for native libraries. He said that the behavior I'm seeing is anamolous and that it shouldn't be happening.

[Update 7/18/2010] I have confirmed that this problem only happens with Batch Build. The problem doesn't happen if you explicitly choose a configuration, nor does the problem happen when running MSBUILD from the command line.

I have opened a bug report on Microsoft Connect. Please vote for it at:
https://connect.microsoft.com/VisualStudio/feedback/details/576146/link-library-dependencies-for-c-does-not-work-with-batch-build

[Update 7/18/2010] Microsoft has reproduced the problem, but has decided not to fix it. If you are reading this, PLEASE let them you that fixing this problem is important to you!

 

目前可用的解决办法:删除所有obj文件;


本文转自海天一鸥博客园博客,原文链接:http://www.cnblogs.com/sgsoft/archive/2010/09/05/1818644.html,如需转载请自行联系原作者

相关文章
|
1月前
|
Kubernetes 测试技术 Go
sealos issue #2157 debug 思路流程记录
sealos issue #2157 debug 思路流程记录
35 0
|
1月前
|
安全 Java Apache
修复了log4j 的bug
修复了log4j 的bug
45 0
|
1月前
|
API Android开发 开发者
debug常见错误,出现debug时出现跑进为条件为false的if语句,DELETE_FAILED_INTERNAL_ERROR Error while In
debug常见错误,出现debug时出现跑进为条件为false的if语句,DELETE_FAILED_INTERNAL_ERROR Error while In
25 5
|
1月前
|
API
debug常见错误,出现debug时出现跑进为条件为false的if语句
debug常见错误,出现debug时出现跑进为条件为false的if语句
20 0
|
12月前
|
Linux C++ Windows
【CMake报错】“检测到_ITERATOR_DEBUG_LEVEL和RuntimeLibrary不匹配” 的解决方案
【CMake报错】“检测到_ITERATOR_DEBUG_LEVEL和RuntimeLibrary不匹配” 的解决方案
284 0
|
Java Maven
未解决:maven:Fatal error compiling: 无效的标记: -arg
未解决:maven:Fatal error compiling: 无效的标记: -arg
104 0
|
C++
VS的一个项目,release/debug/x64/win32的设置有没有办法一次设置?
VS的一个项目,release/debug/x64/win32的设置有没有办法一次设置?
192 0
|
安全 Linux 弹性计算
RHSA-2017:1615: kernel security and bug fix update漏洞预警及修复办法
RHSA-2017:1615: kernel security and bug fix update漏洞预警及修复办法 今天收到了阿里云的短信,说是我的一台ECS有安全漏洞,吓得我赶紧去看了一下。我是不关心云盾的(其实是用不起),自从云盾上次升级后,我其实也没有太在意到底变成什么样子了。
1443 0

热门文章

最新文章