簡體   English   中英

從VS2005升級VS2008(或VS2010)時出現LNK2001和LNK2019錯誤

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

我正在嘗試將舊的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)

H! 那就是總結這個解決方案。 出於某些奇怪的原因,在升級舊的VC6項目時,VS2008和VS2010在處理“附加鏈接依賴項”方面做得非常差(而VS2005似乎可以很好地處理)。 我所缺少的只是進入VS2010中的鏈接選項(在加載並升級了舊的VC6工作區/項目之后),並將五個靜態庫(lib1.lib,lib2.lib等)添加到“其他依賴項”字段(鏈接器) ->輸入),然后將我的輸出文件夾(在其中創建那些.LIB文件)添加到“其他庫目錄”字段(鏈接器->常規)中-都在我的實際.EXE項目的“屬性”下課程。 繁榮,現在它像魅力一樣鏈接。 我對這些CString /模板升級問題(來自MSDN文章等)的“紅色鯡魚”一頭霧水,以至於我完全錯過了顯而易見的地方。 希望這可以幫助某人。 :)

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM