2009-11-06 142 views
0

當我建立我的項目編譯好,但是當鏈接它會引發大量的LNK錯誤!錯誤LNK2001,錯誤LNK2005,錯誤LNK2019在錯誤列表中出現C++ visual studio 2008鏈接問題

>Linking... 
1>MultiCatAttributeInfo.obj : error LNK2019: unresolved external symbol "public: class std::vector<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >,class std::allocator<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > > > __thiscall MultiCatItem::value(void)const " ([email protected]@@[email protected][email protected][email protected]@[email protected]@[email protected]@[email protected]@[email protected]@[email protected][email protected][email protected]@[email protected]@[email protected]@[email protected]@[email protected]@@[email protected]@[email protected]@XZ) referenced in function "public: virtual class boost::dynamic_bitset<unsigned long,class std::allocator<unsigned long> > __thiscall MultiCatAttributeInfo::encode(class Item *)" ([email protected]@@[email protected][email protected]@[email protected]@@[email protected]@[email protected]@@Z) 

我該如何克服這個問題?即時通訊使用Visual Studio 2008,我的解決方案有幾個項目;所有鏈接錯誤,如上所示!

回答

0

好吧,它看起來像你沒有鏈接一些文件。你檢查,以確保你實際上編譯所有的源文件?

沒有任何代碼就很難說任何具體的東西。

0

錯誤說,你還沒有實現或鏈接功能MultiCatItem::value,在功能MultiCatAttributeInfo::encode引用。檢查你是否在項目中包含了合適的cpp文件和MultiCatItem實施。

0

鏈接器試圖找到一個MultiCatItem::value功能,它會在任何一個OBJ文件找到一個實現(即編譯的cpp文件)或編譯的庫(即的.lib文件中,連接屬性指定的輸入部分)。

鏈接器是可以理解的相當迂腐,所以如果你鏈接到一個編譯的lib,確保編譯的庫是用相同的設置編譯的,例如,你編譯的lib不是用Unicode設置編譯的,這意味着對於該方法的簽名會使用charwchar_t改變。

如果您使用的編譯庫使用該工具dumpbin從.LIB,例如傾倒了所有的導出函數/類等。

dumpbin.exe /all somelibrary.lib > out.txt 

並檢查問題鏈接引用的簽名在Visual Studio要查找的.lib中是否相同。

1

如果您使用的是DLL,可能是因爲您沒有通過設置__declspec(dllexport)(以及在導入其他項目中的頭文件時選擇__declspec(dllimport))來正確導出類。然後鏈接器無法看到函數/類。