2010-10-20 110 views
4

我根據找到的指南here編譯我的boost庫,並試圖使用boost文件系統庫。在Visial Studio 2010中鏈接boost庫時遇到問題。

當我添加#include <boost\filesystem\operations.hpp>我收到以下錯誤:

error LNK2028: unresolved token (0A00009A) "class boost::system::error_code __clrcall boost::filesystem2::detail::dir_itr_close(void * &)" ([email protected]@[email protected]@@[email protected]@[email protected]@Z) referenced in function "public: __clrcall boost::filesystem2::detail::dir_itr_imp<class boost::filesystem2::basic_path<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >,struct boost::filesystem2::path_traits> >::~dir_itr_imp<class boost::filesystem2::basic_path<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >,struct boost::filesystem2::path_traits> >(void)" ([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]) 
error LNK2028: unresolved token (0A0000A2) "class boost::system::error_category const & __clrcall boost::system::generic_category(void)" ([email protected]@[email protected]@[email protected]@XZ) referenced in function "void __clrcall `anonymous namespace'::`dynamic initializer for 'void __clrcall boost::system::posix_category::A0x6367c629(void)''(void)" ([email protected][email protected]@[email protected]@[email protected][email protected]@$$FYMXXZ) 
error LNK2028: unresolved token (0A0000A3) "class boost::system::error_category const & __clrcall boost::system::system_category(void)" ([email protected]@[email protected]@[email protected]@XZ) referenced in function "void __clrcall `anonymous namespace'::`dynamic initializer for 'void __clrcall boost::system::native_ecat::A0x6367c629(void)''(void)" ([email protected][email protected]@[email protected]@[email protected][email protected]@$$FYMXXZ) 
error LNK2019: unresolved external symbol "class boost::system::error_code __clrcall boost::filesystem2::detail::dir_itr_close(void * &)" ([email protected]@[email protected]@@[email protected]@[email protected]@Z) referenced in function "public: __clrcall boost::filesystem2::detail::dir_itr_imp<class boost::filesystem2::basic_path<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >,struct boost::filesystem2::path_traits> >::~dir_itr_imp<class boost::filesystem2::basic_path<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >,struct boost::filesystem2::path_traits> >(void)" ([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]) 
error LNK2019: unresolved external symbol "class boost::system::error_category const & __clrcall boost::system::generic_category(void)" ([email protected]@[email protected]@[email protected]@XZ) referenced in function "void __clrcall `anonymous namespace'::`dynamic initializer for 'void __clrcall boost::system::posix_category::A0x6367c629(void)''(void)" ([email protected][email protected]@[email protected]@[email protected][email protected]@$$FYMXXZ) 
error LNK2019: unresolved external symbol "class boost::system::error_category const & __clrcall boost::system::system_category(void)" ([email protected]@[email protected]@[email protected]@XZ) referenced in function "void __clrcall `anonymous namespace'::`dynamic initializer for 'void __clrcall boost::system::native_ecat::A0x6367c629(void)''(void)" ([email protected][email protected]@[email protected]@[email protected][email protected]@$$FYMXXZ) 

如果我編譯不包括operations.hpp它工作正常。問題是,當我使用#define BOOST_LIB_DIAGNOSTIC這表明,它是在Boost庫正確鏈接:

Linking to lib file: libboost_filesystem-vc100-mt-gd-1_44.lib 
Linking to lib file: libboost_system-vc100-mt-gd-1_44.lib 
+1

很棒的建議:http://stackoverflow.com/questions/2629421/how-to-use-boost-in-visual-studio-2010 – karlphillip 2010-10-20 12:14:10

回答

1

在項目選項(在連接選項組)添加缺少的庫的依賴關係,並添加路徑提振附加目錄中的庫。或者,要啓用自動鏈接(如果您將boost編譯爲DLL),請在C++選項的項目中的預處理器符號中定義BOOST_ALL_DYN_LINK。