我使用由BoostPro Computing安裝程序安裝的boost庫。我在Windows 7 64位機器上使用VS 2010。我想鏈接到動態提升,所以我選擇了安裝程序中的前兩個選項(Multithreaded Debug DLL和Multithreaded DLL,我相信他們被稱爲)。一些安裝庫的一個例子是:當在VS2010中動態鏈接Boost 1.51.0時,鏈接器錯誤LNK2019
boost_bzip2-vc100-mt-1_51.lib
boost_bzip2-vc100-mt-gd-1_51.lib
當鏈接在我的項目,以提高,我也確信定義BOOST_ALL_DYN_LINK
。我正在使用filesystem
工具集。
在我打開我BOOST_LIB_DIAGNOSTIC
看到生成輸出以下消息:
1>main.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const __thiscall boost::filesystem::path::string(void)const " ([email protected]@[email protected]@@[email protected][email protected]@[email protected]@[email protected]@[email protected]@[email protected]@XZ) referenced in function _main
1>main.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: __thiscall boost::filesystem::path::~path(void)" ([email protected]@[email protected]@[email protected]) referenced in function _main
1>main.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) class boost::filesystem::path __cdecl boost::filesystem::detail::unique_path(class boost::filesystem::path const &,class boost::system::error_code *)" ([email protected]@[email protected]@@[email protected]@[email protected][email protected]@[email protected]@Z) referenced in function "class boost::filesystem::path __cdecl boost::filesystem::unique_path(class boost::filesystem::path const &)" ([email protected]@[email protected]@[email protected]@[email protected]@Z)
1>main.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: static class std::codecvt<wchar_t,char,int> const & __cdecl boost::filesystem::path::codecvt(void)" ([email protected]@[email protected]@@[email protected][email protected]@@XZ) referenced in function "public: __thiscall boost::filesystem::path::path<char const [20]>(char const (&)[20],void *)" ([email protected][email protected]@[email protected]@@[email protected]@$$CBDPAX[email protected])
1>main.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) void __cdecl boost::filesystem::path_traits::convert(char const *,char const *,class std::basic_string<wchar_t,struct std::char_traits<wchar_t>,class std::allocator<wchar_t> > &,class std::codecvt<wchar_t,char,int> const &)" ([email protected][email protected]@[email protected]@[email protected][email protected][email protected]@@[email protected][email protected]@@[email protected]@[email protected][email protected]@@Z) referenced in function "void __cdecl boost::filesystem::path_traits::dispatch<class std::basic_string<wchar_t,struct std::char_traits<wchar_t>,class std::allocator<wchar_t> > >(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &,class std::basic_string<wchar_t,struct std::char_traits<wchar_t>,class std::allocator<wchar_t> > &,class std::codecvt<wchar_t,char,int> 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][email protected]@@[email protected][email protected]@@[email protected][email protected][email protected]@@Z)
1>main.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) class boost::system::error_category const & __cdecl boost::system::generic_category(void)" ([email protected]@[email protected]@[email protected]@XZ) referenced in function "void __cdecl boost::system::`dynamic initializer for 'posix_category''(void)" ([email protected]@[email protected]@YAXXZ)
1>main.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) class boost::system::error_category const & __cdecl boost::system::system_category(void)" ([email protected]@[email protected]@[email protected]@XZ) referenced in function "void __cdecl boost::system::`dynamic initializer for 'native_ecat''(void)" ([email protected]@[email protected]@YAXXZ)
應該
不被auto-link.hpp
照顧:
1> Linking to lib file: boost_filesystem-vc100-mt-gd-1_51.lib
1> Linking to lib file: boost_system-vc100-mt-gd-1_51.lib
但那些都是很快跟進我的鏈接對我來說?我並沒有特別要求鏈接到項目,因爲自動鏈接器似乎正確地識別了一切。那麼我怎麼會錯過這些東西呢?另外,它們被聲明爲dllimport
,所以鏈接器不應該讓它們獨立,並期望它們在運行時被發現?
謝謝!
更新:我決定潛入第二個鏈接器錯誤。它基本上說它找不到path
類的析構函數。在filesystem
庫運行dumpbin
後,我注意到,這條線是文件中:
[email protected]@[email protected]@[email protected] (public: __cdecl boost::filesystem::path::~path(void))
但是,這顯然不符合什麼連接正在尋找,這是本場比賽:
"__declspec(dllimport) public: __thiscall boost::filesystem::path::~path(void)" ([email protected]@[email protected]@[email protected])
請注意,鏈接器正在尋找一個DLL導入版本,但庫本身似乎並沒有提供一個......不知道該從哪裏走,但它似乎是重要的信息!
感謝您的建議。這些庫確實存在 - 我測試了刪除「鏈接到lib ...」中提到的庫中的一個,並且我收到一個錯誤,指出文件丟失。所以提到的文件確實被正確地鏈接到了,但似乎有些符號或定義丟失了? – aardvarkk
.libs是否使用Unicode編譯,因爲它看起來像是在鏈接多字節字符集?如果您在.lib上執行了dumpbin/ALL,您可以看到正在導出的內容。如果所有的類都使用wchar_t,那麼你就知道這個問題了。 – snowdude
偉大的建議 - 我會看看! – aardvarkk