Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/cplusplus/142.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C++ 从VS2005升级到VS2008(或VS2010)期间LNK2001和LNK2019错误_C++_Visual Studio 2008_Linker - Fatal编程技术网

C++ 从VS2005升级到VS2008(或VS2010)期间LNK2001和LNK2019错误

C++ 从VS2005升级到VS2008(或VS2010)期间LNK2001和LNK2019错误,c++,visual-studio-2008,linker,C++,Visual Studio 2008,Linker,我正在尝试将旧的VC6解决方案升级到VS2010。一切都编译得很好(在一些代码更改以处理一些VC++更改之后),但它拒绝链接。我有6个静态库——全部设置为“在共享DLL中使用MFC”和“不使用ATL”——Unicode字符集,还有一个应用程序(.EXE)设置为“使用标准Windows库”和“不使用ATL”(当然也是Unicode)。此解决方案使用Visual Studio 2005(SP1)可以很好地编译/链接,但在VS2008和VS2010上链接都失败。错误消息主要与“CStringT”有关。

我正在尝试将旧的VC6解决方案升级到VS2010。一切都编译得很好(在一些代码更改以处理一些VC++更改之后),但它拒绝链接。我有6个静态库——全部设置为“在共享DLL中使用MFC”和“不使用ATL”——Unicode字符集,还有一个应用程序(.EXE)设置为“使用标准Windows库”和“不使用ATL”(当然也是Unicode)。此解决方案使用Visual Studio 2005(SP1)可以很好地编译/链接,但在VS2008和VS2010上链接都失败。错误消息主要与“CStringT”有关。从我所研究的所有内容来看,我也应该在VS2005中看到这些CStringT链接错误(也就是当CString更改为模板类时),但正如我所说的,它在VS2005中链接良好。我已经尝试了这里和其他地方推荐的每一个技巧和技巧(例如,在stdafx.h头中显式导入CStringT的模板类),但没有成功。有人有什么新想法吗?我将粘贴下面的错误样本以供参考。谢谢

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)
错误LNK2001:未解析的外部符号“public:class ATL::CStringT const&\u thiscall SomeExceptionClass::GetErrorMessage(void)const”(?GetErrorMessage@SomeExceptionClass@@QBEABV$CStringT@_WV?$StrTraitMFC@_WV?$ChTraitsCRT@_W@ATL@@@@ATL@@@XZ)
错误LNK2001:未解析的外部符号“public:class ATL::CStringT const&u thiscall SomeExceptionClass::GetErrorMessage(void)const”(?GetErrorMessage@SomeExceptionClass@@QBEABV$CStringT@_WV?$StrTraitMFC@_WV?$ChTraitsCRT@_W@ATL@@@@ATL@@@XZ)
错误LNK2019:未解析的外部符号“public:class ATL::CStringT const&u thiscall SomeExceptionClass::GetErrorMessage(void)const”(?GetErrorMessage@SomeExceptionClass@@QBEABV$CStringT@_WV?$StrTraitMFC@_WV?$ChTraitsCRT@_W@ATL@@@@ATL@@@XZ)在函数\uu catch$中引用?Init@SomeOtherClass@@卡埃帕_W00000@Z$0
错误LNK2001:未解析的外部符号“public:class ATL::CStringT const&u thiscall SomeExceptionClass::GetErrorMessage(void)const”(?GetErrorMessage@SomeExceptionClass@@QBEABV$CStringT@_WV?$StrTraitMFC@_WV?$ChTraitsCRT@_W@ATL@@@@ATL@@@XZ)
错误LNK2001:未解析的外部符号“public:class ATL::CStringT const&u thiscall SomeExceptionClass::GetErrorMessage(void)const”(?GetErrorMessage@SomeExceptionClass@@QBEABV$CStringT@_WV?$StrTraitMFC@_WV?$ChTraitsCRT@_W@ATL@@@@ATL@@@XZ)
错误LNK2001:未解析的外部符号“public:class ATL::CStringT const&u thiscall SomeExceptionClass::GetErrorMessage(void)const”(?GetErrorMessage@SomeExceptionClass@@QBEABV$CStringT@_WV?$StrTraitMFC@_WV?$ChTraitsCRT@_W@ATL@@@@ATL@@@XZ)
错误LNK2001:未解析的外部符号“public:void\u thiscall SomeDatabaseClass::ExecDirect(类ATL::CStringT const&)”(?ExecDirect@SomeDatabaseClass@@QAEXABV$CStringT@_WV?$StrTraitMFC@_WV?$ChTraitsCRT@_W@ATL@@@@ATL@@@Z)
错误LNK2001:未解析的外部符号“public:void\u thiscall SomeDatabaseClass::ExecDirect(类ATL::CStringT const&)”(?ExecDirect@SomeDatabaseClass@@QAEXABV$CStringT@_WV?$StrTraitMFC@_WV?$ChTraitsCRT@_W@ATL@@@@ATL@@@Z)

DUH!这就是这个解决方案的总结。出于某种奇怪的原因,VS2008和VS2010在升级旧的VC6项目时处理“额外的链接依赖项”的工作非常糟糕(而VS2005似乎处理得很好)。我所缺少的只是进入VS2010中的链接选项(在加载和升级我的旧VC6工作区/项目之后),将我的五个静态库(lib1.lib、lib2.lib等)添加到“附加依赖项”字段(Linker->Input),然后将我的输出文件夹(创建这些.lib文件的地方)添加到“附加库目录”中字段(Linker->General)--当然,所有字段都位于实际.EXE项目的属性下。繁荣,现在它像一个魅力链接。我被这些CString/template升级问题(来自MSDN文章等)的“红鲱鱼”弄得支离破碎,以至于我完全忽略了显而易见的问题。希望这对以后的人有所帮助。:)

可能与“将wchar\u t视为内置类型”选项有关,请参见C++->Language options