CRT版本10.0的LNK2022和LNK2034链接器错误 [英] LNK2022 and LNK2034 linker errors with version 10.0 of the CRT

查看:289
本文介绍了CRT版本10.0的LNK2022和LNK2034链接器错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

很抱歉打扰任何人,但是我已经研究了好几个小时,还没有解决方法:

Sorry to bother anyone with this question, but I've been researching this for hours, with no resolution yet:

我正在将相当庞大的应用程序移植到Visual Studio 2010中的10.0 CRT(编译器)上.该应用程序是使用/clr的托管C ++/CLI.大部分代码是本机代码(95%),其中有一些托管部分.

I am porting a rather massive application to the 10.0 CRT (compiler) in Visual Studio 2010. The app is managed C++/CLI that uses /clr. Most of the code is native (95%), with a few managed portions here and there in it.

所以我的工作是在.vcxproj中进行切换,以定位较新的10.0 CRT(即编译器).我们以前使用的是v90,或者使用VS 2008 SP1随附的VC编译器.

So my job is to make the switch in the .vcxproj to target the newer 10.0 CRT (i.e. compiler). We were previously using v90, or using the VC compiler that came with VS 2008 SP1.

好,那么突破性的改变吗?似乎实际上是一堆.我修复了一些处理集合的迭代器问题,这些问题都非常容易.

Ok, so breaking changes? Seems like a bunch actually. I fixed a few iterator issues dealing with sets, which all was all pretty easy.

但是这些链接器错误使我丧命.任何帮助将不胜感激:

But these linker errors are killing me. Any help would be appreciated:

1>MSVCMRTD.lib(locale0_implib.obj) : error LNK2022: metadata operation failed (80131195) : Custom attributes are not consistent: (0x0c0001c0).
1>MSVCMRTD.lib(locale0_implib.obj) : error LNK2022: metadata operation failed (80131195) : Custom attributes are not consistent: (0x0c0001c5).
...

1>MSVCMRTD.lib(locale0_implib.obj) : error LNK2034: metadata inconsistent with COFF symbol table: symbol '??0?$allocator@D@std@@$$FQAE@ABV01@@Z' (06000141) has inconsistent metadata with (0A000F75) in identity.obj
1>MSVCMRTD.lib(locale0_implib.obj) : error LNK2034: metadata inconsistent with COFF symbol table: symbol '??0?$allocator@D@std@@$$FQAE@ABV01@@Z' (06000141) has inconsistent metadata with (0A000F76) in ICustAttribCollapseManagerImp.obj
... (repeated hundreds of times)

我继续未修饰符号:

??0?$allocator@D@std@@$$FQAE@ABV01@@Z

并得到:

public: __thiscall std::allocator<char>::allocator<char>(class std::allocator<char> const &)

据我所知,msvcmrtd.lib文件的std :: allocator具有一种编译方式,而我的项目设置(#pragmamanaged ??)中的其他内容则具有另一种编译方式.但是,如果是这样,我要寻找什么?多年来,使用旧的编译器都可以很好地进行编译.

So, as I understand it, the msvcmrtd.lib file has this std::allocator compiled one way, and something else in my project settings (#pragma managed ??) is compiled another, different way. But if so, what do I look for? This has been compiling fine for years using the old compilers.

注意: 我们目前使用的是3.5 .NET框架(不确定是否有帮助...我对此表示怀疑)

Note: We currently the 3.5 .NET framework (Not sure if that helps or not... I doubt it)

谢谢

推荐答案

这是很难诊断的问题,链接器错误会散发出臭味,并且记录薄弱.在

This is a hard to diagnose problem, the linker errors stink and are poorly documented. There's a post from Stephan Lavavej, the STL maintainer at Microsoft about it in this thread, bottom of the page. I have to say I don't see much of any advice in it, beyond trying to disable iterator debugging in your project settings (_HAS_ITERATOR_DEBUGGING = 0 in the preprocessor definitons).

您确实需要考虑进行代码审查.看起来您好像正在将STL代码编译为托管代码.总体来说,这种方法有效(减去了链接程序的麻烦),但这确实是错误的事情.将STL集合类留给您的本机代码,在托管代码中使用BCL集合类(List<>等).

You do need to consider a code review. It sure looks like you are compiling STL code into managed code. That works in general (minus the linker hassle) but it is really the wrong thing to do. Leave the STL collection classes to your native code, use the BCL collection classes (List<> etc) in your managed code.

这篇关于CRT版本10.0的LNK2022和LNK2034链接器错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆