简体   繁体   English

从VS2005升级VS2008(或VS2010)时出现LNK2001和LNK2019错误

[英]LNK2001 and LNK2019 error during VS2008 (or VS2010) upgrade from VS2005

I am attempting to upgrade an old VC6 solution to VS2010. 我正在尝试将旧的VC6解决方案升级到VS2010。 Everything compiles fine (after a few code changes to handle some VC++ changes), but it refuses to link. 一切都可以正常编译(在进行了一些代码更改以处理某些VC ++更改之后),但是它拒绝链接。 I have 6 static libraries -- all set to "Use MFC in a Shared DLL" and "Not Using ATL" -- Unicode character set, and one Application (.EXE) set to "Use Standard Windows Libraries" and "Not Using ATL" (also Unicode, of course). 我有6个静态库-都设置为“在共享DLL中使用MFC”和“不使用ATL”-Unicode字符集,一个应用程序(.EXE)设置为“使用标准Windows库”和“不使用ATL” ”(当然也是Unicode)。 This solution compiles/links fine using Visual Studio 2005 (SP1), but linking fails on both VS2008 and VS2010. 使用Visual Studio 2005(SP1),此解决方案可以很好地进行编译/链接,但是在VS2008和VS2010上链接都失败。 The error messages are predominantly related to "CStringT". 错误消息主要与“ CStringT”有关。 From everything I've researched, I should have seen these CStringT link errors in VS2005 also (that is when CString changed to template class), but as I said, it links fine in VS2005. 从我研究的所有内容中,我也应该已经在VS2005中看到了这些CStringT链接错误(即,当CString更改为模板类时),但是正如我所说的,它在VS2005中可以很好地链接。 I've tried every tip & trick that has been recommended here and elsewhere (ie explicitly importing the template class for CStringT in my stdafx.h header), but no luck. 我尝试了这里和其他地方推荐的所有技巧(例如,在我的stdafx.h标头中显式导入CStringT的模板类),但是没有运气。 Anyone have any NEW ideas? 有人有新想法吗? I'll paste a sampling of the errors below for reference. 我将在下面粘贴错误示例以供参考。 Thanks! 谢谢!

error LNK2001: unresolved external symbol "public: class ATL::CStringT<wchar_t,class StrTraitMFC<wchar_t,class ATL::ChTraitsCRT<wchar_t> > > const & __thiscall SomeExceptionClass::GetErrorMessage(void)const " (?GetErrorMessage@SomeExceptionClass@@QBEABV?$CStringT@_WV?$StrTraitMFC@_WV?$ChTraitsCRT@_W@ATL@@@@@ATL@@XZ)   

error LNK2001: unresolved external symbol "public: class ATL::CStringT<wchar_t,class StrTraitMFC<wchar_t,class ATL::ChTraitsCRT<wchar_t> > > const & __thiscall SomeExceptionClass::GetErrorMessage(void)const " (?GetErrorMessage@SomeExceptionClass@@QBEABV?$CStringT@_WV?$StrTraitMFC@_WV?$ChTraitsCRT@_W@ATL@@@@@ATL@@XZ)

error LNK2019: unresolved external symbol "public: class ATL::CStringT<wchar_t,class StrTraitMFC<wchar_t,class ATL::ChTraitsCRT<wchar_t> > > const & __thiscall SomeExceptionClass::GetErrorMessage(void)const " (?GetErrorMessage@SomeExceptionClass@@QBEABV?$CStringT@_WV?$StrTraitMFC@_WV?$ChTraitsCRT@_W@ATL@@@@@ATL@@XZ) referenced in function __catch$?Init@SomeOtherClass@@QAEHPA_W00000@Z$0

error LNK2001: unresolved external symbol "public: class ATL::CStringT<wchar_t,class StrTraitMFC<wchar_t,class ATL::ChTraitsCRT<wchar_t> > > const & __thiscall SomeExceptionClass::GetErrorMessage(void)const " (?GetErrorMessage@SomeExceptionClass@@QBEABV?$CStringT@_WV?$StrTraitMFC@_WV?$ChTraitsCRT@_W@ATL@@@@@ATL@@XZ)

error LNK2001: unresolved external symbol "public: class ATL::CStringT<wchar_t,class StrTraitMFC<wchar_t,class ATL::ChTraitsCRT<wchar_t> > > const & __thiscall SomeExceptionClass::GetErrorMessage(void)const " (?GetErrorMessage@SomeExceptionClass@@QBEABV?$CStringT@_WV?$StrTraitMFC@_WV?$ChTraitsCRT@_W@ATL@@@@@ATL@@XZ)

error LNK2001: unresolved external symbol "public: class ATL::CStringT<wchar_t,class StrTraitMFC<wchar_t,class ATL::ChTraitsCRT<wchar_t> > > const & __thiscall SomeExceptionClass::GetErrorMessage(void)const " (?GetErrorMessage@SomeExceptionClass@@QBEABV?$CStringT@_WV?$StrTraitMFC@_WV?$ChTraitsCRT@_W@ATL@@@@@ATL@@XZ)

error LNK2001: unresolved external symbol "public: void __thiscall SomeDatabaseClass::ExecDirect(class ATL::CStringT<wchar_t,class StrTraitMFC<wchar_t,class ATL::ChTraitsCRT<wchar_t> > > const &)" (?ExecDirect@SomeDatabaseClass@@QAEXABV?$CStringT@_WV?$StrTraitMFC@_WV?$ChTraitsCRT@_W@ATL@@@@@ATL@@@Z)

error LNK2001: unresolved external symbol "public: void __thiscall SomeDatabaseClass::ExecDirect(class ATL::CStringT<wchar_t,class StrTraitMFC<wchar_t,class ATL::ChTraitsCRT<wchar_t> > > const &)" (?ExecDirect@SomeDatabaseClass@@QAEXABV?$CStringT@_WV?$StrTraitMFC@_WV?$ChTraitsCRT@_W@ATL@@@@@ATL@@@Z)

DUH! H! That about sums up this solution. 那就是总结这个解决方案。 For some strange reason, VS2008 and VS2010 do a incredibly poor job of handling "additional link dependencies" when upgrading an old VC6 project (while VS2005 seems to handle it just fine). 出于某些奇怪的原因,在升级旧的VC6项目时,VS2008和VS2010在处理“附加链接依赖项”方面做得非常差(而VS2005似乎可以很好地处理)。 All I was missing was going into Link options in VS2010 (after loading & upgrading my old VC6 workspace/projects) and adding my five static libraries (lib1.lib, lib2.lib, etc.) to the "Additional Dependencies" field (Linker->Input), and then adding my output folder[s] (where those .LIB files are created) to the "Additional Library Directories" field (Linker->General) -- all under Properties for my actual .EXE project, of course. 我所缺少的只是进入VS2010中的链接选项(在加载并升级了旧的VC6工作区/项目之后),并将五个静态库(lib1.lib,lib2.lib等)添加到“其他依赖项”字段(链接器) ->输入),然后将我的输出文件夹(在其中创建那些.LIB文件)添加到“其他库目录”字段(链接器->常规)中-都在我的实际.EXE项目的“属性”下课程。 Boom, now it links like a charm. 繁荣,现在它像魅力一样链接。 I got so sidetracked with the "red herring" of these CString/template upgrade issues (from MSDN articles, etc.), that I completely missed the obvious. 我对这些CString /模板升级问题(来自MSDN文章等)的“红色鲱鱼”一头雾水,以至于我完全错过了显而易见的地方。 Hope this helps someone down the road. 希望这可以帮助某人。 :) :)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM