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
很棒的建议:http://stackoverflow.com/questions/2629421/how-to-use-boost-in-visual-studio-2010 – karlphillip 2010-10-20 12:14:10