在 Visual Studio 2010 中链接 boost 库时出现问题。

2024-03-30

我根据找到的指南编译了我的boost库here https://stackoverflow.com/questions/2629421/how-to-use-boost-in-visual-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 * &)" (?dir_itr_close@detail@filesystem2@boost@@$$FYM?AVerror_code@system@3@AAPAX@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)" (??1?$dir_itr_imp@V?$basic_path@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@Upath_traits@filesystem2@boost@@@filesystem2@boost@@@detail@filesystem2@boost@@$$FQAM@XZ)
error LNK2028: unresolved token (0A0000A2) "class boost::system::error_category const & __clrcall boost::system::generic_category(void)" (?generic_category@system@boost@@$$FYMABVerror_category@12@XZ) referenced in function "void __clrcall `anonymous namespace'::`dynamic initializer for 'void __clrcall boost::system::posix_category::A0x6367c629(void)''(void)" (???__E?A0x6367c629@posix_category@system@boost@@YMXXZ@?A0x6367c629@@$$FYMXXZ)
error LNK2028: unresolved token (0A0000A3) "class boost::system::error_category const & __clrcall boost::system::system_category(void)" (?system_category@system@boost@@$$FYMABVerror_category@12@XZ) referenced in function "void __clrcall `anonymous namespace'::`dynamic initializer for 'void __clrcall boost::system::native_ecat::A0x6367c629(void)''(void)" (???__E?A0x6367c629@native_ecat@system@boost@@YMXXZ@?A0x6367c629@@$$FYMXXZ)
error LNK2019: unresolved external symbol "class boost::system::error_code __clrcall boost::filesystem2::detail::dir_itr_close(void * &)" (?dir_itr_close@detail@filesystem2@boost@@$$FYM?AVerror_code@system@3@AAPAX@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)" (??1?$dir_itr_imp@V?$basic_path@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@Upath_traits@filesystem2@boost@@@filesystem2@boost@@@detail@filesystem2@boost@@$$FQAM@XZ)
error LNK2019: unresolved external symbol "class boost::system::error_category const & __clrcall boost::system::generic_category(void)" (?generic_category@system@boost@@$$FYMABVerror_category@12@XZ) referenced in function "void __clrcall `anonymous namespace'::`dynamic initializer for 'void __clrcall boost::system::posix_category::A0x6367c629(void)''(void)" (???__E?A0x6367c629@posix_category@system@boost@@YMXXZ@?A0x6367c629@@$$FYMXXZ)
error LNK2019: unresolved external symbol "class boost::system::error_category const & __clrcall boost::system::system_category(void)" (?system_category@system@boost@@$$FYMABVerror_category@12@XZ) referenced in function "void __clrcall `anonymous namespace'::`dynamic initializer for 'void __clrcall boost::system::native_ecat::A0x6367c629(void)''(void)" (???__E?A0x6367c629@native_ecat@system@boost@@YMXXZ@?A0x6367c629@@$$FYMXXZ)

如果我编译时不包含操作.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

在项目选项(链接器选项组)中,在依赖项中添加缺少的库,并在其他目录中添加 boost 库的路径。或者,要启用自动链接(如果将 boost 编译为 DLL),请在项目中 C++ 选项的预处理器符号中定义 BOOST_ALL_DYN_LINK。

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

在 Visual Studio 2010 中链接 boost 库时出现问题。 的相关文章

随机推荐