带有Boost Regex库的未解决的外部对象

Unresolved external objects with boost regex library

本文关键字:未解决 对象 外部 Boost Regex 带有      更新时间:2023-10-16

我刚刚开始学习C ,现在我尝试使用Boost库。顺便说一句,我正在使用Visual Studio 2015 Professional。

我已经下载了文件 BOOST_1_1_5_0-BIN-MSVC-ALL-32-64.7Z ,并遵循本教程中的说明。但是当我尝试编译时,我会遇到错误:

1>libboost_regex-vc120-mt-gd-1_55.liberror LNK2019: external symbol "__declspec(dllimport) public: __thiscall std::exception::exception(char const * const &)" (__imp_??0exception@std@@QAE@ABQBD@Z) sin resolver al que se hace referencia en la función "public: __thiscall std::logic_error::logic_error(char const *)" (??0logic_error@std@@QAE@PBD@Z)
1>libboost_regex-vc120-mt-gd-1_55.lib(regex.obj) : error LNK2001: external symbol "__declspec(dllimport) public: __thiscall std::exception::exception(char const * const &)" (__imp_??0exception@std@@QAE@ABQBD@Z) sin resolver
1>libboost_regex-vc120-mt-gd-1_55.lib(w32_regex_traits.obj) : error LNK2001: external symbol "__declspec(dllimport) public: __thiscall std::exception::exception(char const * const &)" (__imp_??0exception@std@@QAE@ABQBD@Z) sin resolver
1>libboost_regex-vc120-mt-gd-1_55.lib(instances.obj) : error LNK2019: external symbol "__declspec(dllimport) public: struct std::_Iterator_base12 * * __thiscall std::_Container_base12::_Getpfirst(void)const " (__imp_?_Getpfirst@_Container_base12@std@@QBEPAPAU_Iterator_base12@2@XZ) sin resolver al que se hace referencia en la función "protected: void __thiscall std::_Tree<class std::_Tmap_traits<int,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >,struct std::less<int>,class std::allocator<struct std::pair<int const ,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > > >,0> >::_Orphan_ptr(class std::_Tree<class std::_Tmap_traits<int,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >,struct std::less<int>,class std::allocator<struct std::pair<int const ,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > > >,0> > &,struct std::_Tree_node<struct std::pair<int const ,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > >,void *> *)const " (?_Orphan_ptr@?$_Tree@V?$_Tmap_traits@HV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@U?$less@H@2@V?$allocator@U?$pair@$$CBHV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@std@@@2@$0A@@std@@@std@@IBEXAAV12@PAU?$_Tree_node@U?$pair@$$CBHV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@std@@PAX@2@@Z)
1>libboost_regex-vc120-mt-gd-1_55.lib(instances.obj) : error LNK2019: external symbol "__declspec(dllimport) public: void __thiscall std::_Container_base12::_Swap_all(struct std::_Container_base12 &)" (__imp_?_Swap_all@_Container_base12@std@@QAEXAAU12@@Z) sin resolver al que se hace referencia en la función "public: void __thiscall std::vector<struct boost::sub_match<char const *>,class std::allocator<struct boost::sub_match<char const *> > >::swap(class std::vector<struct boost::sub_match<char const *>,class std::allocator<struct boost::sub_match<char const *> > > &)" (?swap@?$vector@U?$sub_match@PBD@boost@@V?$allocator@U?$sub_match@PBD@boost@@@std@@@std@@QAEXAAV12@@Z)
1>libboost_regex-vc120-mt-gd-1_55.lib(regex_raw_buffer.obj) : error LNK2001: external symbol "__declspec(dllimport) char const * __cdecl std::_Winerror_map(int)" (__imp_?_Winerror_map@std@@YAPBDH@Z) sin resolver
1>libboost_regex-vc120-mt-gd-1_55.lib(instances.obj) : error LNK2001: external symbol "__declspec(dllimport) char const * __cdecl std::_Winerror_map(int)" (__imp_?_Winerror_map@std@@YAPBDH@Z) sin resolver
1>libboost_regex-vc120-mt-gd-1_55.lib(regex.obj) : error LNK2001: external symbol "__declspec(dllimport) char const * __cdecl std::_Winerror_map(int)" (__imp_?_Winerror_map@std@@YAPBDH@Z) sin resolver
1>libboost_regex-vc120-mt-gd-1_55.lib(regex_traits_defaults.obj) : error LNK2001: external symbol "__declspec(dllimport) char const * __cdecl std::_Winerror_map(int)" (__imp_?_Winerror_map@std@@YAPBDH@Z) sin resolver
1>libboost_regex-vc120-mt-gd-1_55.lib(w32_regex_traits.obj) : error LNK2001: external symbol "__declspec(dllimport) char const * __cdecl std::_Winerror_map(int)" (__imp_?_Winerror_map@std@@YAPBDH@Z) sin resolver
1>libboost_regex-vc120-mt-gd-1_55.lib(w32_regex_traits.obj) : error LNK2019: external symbol "__declspec(dllimport) public: bool __thiscall type_info::operator==(class type_info const &)const " (__imp_??8type_info@@QBE_NABV0@@Z) sin resolver al que se hace referencia en la función "public: virtual void * __thiscall boost::detail::sp_counted_impl_pd<struct HINSTANCE__ *,void (__cdecl*)(void *)>::get_deleter(class type_info const &)" (?get_deleter@?$sp_counted_impl_pd@PAUHINSTANCE__@@P6AXPAX@Z@detail@boost@@UAEPAXABVtype_info@@@Z)
1>D:FuentesCPPConsoleReadDirDebugConsoleReadDir.exe : fatal error LNK1120: 5 unresolved external

我已经更新了其他库目录路径: D:Descargasboost_1_55_0-bin-msvc-all-32-64boost_1_55_0lib32-msvc-12.0

我需要做什么才能添加外部对象?

这是因为您的构建版本的Boost版本早于Visual Studio 2015,请参见如何指定,哪个版本的Boost库链接到?

当前版本的Boost,1.62工作正常。如果找不到预先构建的二进制文件,那么可以很容易地使用MSVC构建Windows库,请参见:Boost安装Windows