使用 boost 正则表达式库未解析的外部对象
Posted
技术标签:
【中文标题】使用 boost 正则表达式库未解析的外部对象【英文标题】:Unresolved external objects with boost regex library 【发布时间】:2016-11-24 15:01:28 【问题描述】:我刚刚开始学习 C++,现在我尝试使用 Boost 库。顺便说一句,我使用的是 Visual Studio 2015 Professional。
我已经下载了文件 boost_1_55_0-bin-msvc-all-32-64.7z 并按照tutorial 中的说明进行操作。但是当我尝试编译时,我得到了错误:
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:\Fuentes\CPP\ConsoleReadDir\Debug\ConsoleReadDir.exe : fatal error LNK1120: 5 unresolved external
我已更新附加库目录,路径为:D:\Descargas\boost_1_55_0-bin-msvc-all-32-64\boost_1_55_0\lib32-msvc-12.0
。
添加外部对象需要做什么?
【问题讨论】:
【参考方案1】:这是因为您构建的 boost 版本早于 Visual Studio 2015,请参阅 How do I specify, which version of boost library to link to?
boost、1.62
的当前版本工作正常。如果您找不到预构建的二进制文件,那么使用 MSVC 构建 Windows 库很容易,请参阅:boost installation in windows
【讨论】:
以上是关于使用 boost 正则表达式库未解析的外部对象的主要内容,如果未能解决你的问题,请参考以下文章