regex_search.hpp:56:对`boost :: re_detail_106100 :: perl_matcher的未定义引用 [英] regex_search.hpp:56: undefined reference to `boost::re_detail_106100::perl_matcher

查看:353
本文介绍了regex_search.hpp:56:对`boost :: re_detail_106100 :: perl_matcher的未定义引用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

从boost 1.58更新到1.61后,链接失败,并显示以下错误:

After updateting from boost 1.58 to 1.61, linking fails with the following error:

In function `bool boost::regex_search<__gnu_cxx::__normal_iterator<char const*, std::string>, std::allocator<boost::sub_match<__gnu_cxx::__normal_iterator<char const*, std::string> > >, char, boost::regex_traits<char, boost::cpp_regex_traits<char> > >(__gnu_cxx::__normal_iterator<char const*, std::string>, __gnu_cxx::__normal_iterator<char const*, std::string>, boost::match_results<__gnu_cxx::__normal_iterator<char const*, std::string>, std::allocator<boost::sub_match<__gnu_cxx::__normal_iterator<char const*, std::string> > > >&, boost::basic_regex<char, boost::regex_traits<char, boost::cpp_regex_traits<char> > > const&, boost::regex_constants::_match_flags, __gnu_cxx::__normal_iterator<char const*, std::string>)':
/usr/include/boost/regex/v4/regex_search.hpp:56: undefined reference to `boost::re_detail_106100::perl_matcher<__gnu_cxx::__normal_iterator<char const*, std::string>, std::allocator<boost::sub_match<__gnu_cxx::__normal_iterator<char const*, std::string> > >, boost::regex_traits<char, boost::cpp_regex_traits<char> > >::find()'
CMakeFiles/havoc.dir/src/helpers.cpp.o: In function `boost::re_detail_106100::perl_matcher<__gnu_cxx::__normal_iterator<char const*, std::string>, std::allocator<boost::sub_match<__gnu_cxx::__normal_iterator<char const*, std::string> > >, boost::regex_traits<char, boost::cpp_regex_traits<char> > >::perl_matcher(__gnu_cxx::__normal_iterator<char const*, std::string>, __gnu_cxx::__normal_iterator<char const*, std::string>, boost::match_results<__gnu_cxx::__normal_iterator<char const*, std::string>, std::allocator<boost::sub_match<__gnu_cxx::__normal_iterator<char const*, std::string> > > >&, boost::basic_regex<char, boost::regex_traits<char, boost::cpp_regex_traits<char> > > const&, boost::regex_constants::_match_flags, __gnu_cxx::__normal_iterator<char const*, std::string>)':
/usr/include/boost/regex/v4/perl_matcher.hpp:382: undefined reference to `boost::re_detail_106100::perl_matcher<__gnu_cxx::__normal_iterator<char const*, std::string>, std::allocator<boost::sub_match<__gnu_cxx::__normal_iterator<char const*, std::string> > >, boost::regex_traits<char, boost::cpp_regex_traits<char> > >::construct_init(boost::basic_regex<char, boost::regex_traits<char, boost::cpp_regex_traits<char> > > const&, boost::regex_constants::_match_flags)'

我使用cmake像这样链接到Boost:

I use cmake to link against boost like this:

find_package(Boost COMPONENTS chrono system filesystem thread regex random REQUIRED)    
target_link_libraries (myprog
      ${Boost_REGEX_LIBRARY}
)

我搜索了boost的更新日志,但是找不到可能导致cmake链接失败的特定内容.就像我说的那样:1.58可以完美地工作.

I searched the changelog of boost but could not find anything specific that might cause the cmake linking to fail. Like I said: it works perfectly with 1.58.

libboost-regex1.61.0损坏了还是链接改变了?

Is libboost-regex1.61.0 broken or did the linking change somehow?

更新:2016年11月14日: Boost的变更日志显示名称空间已从"re_detail"重命名为"BOOST_REGEX_DETAIL_NS".

Update: 14.11.2016: The Changelog of Boost shows that the namespace was renamed from "re_detail" to "BOOST_REGEX_DETAIL_NS".

我使用的是Kali Rolloing版本,在我看来,installedboost lib 1.61与boost 1.61源不匹配.我将尝试手动安装lib,并检查是否可以解决问题.

I use Kali Rolloing release and it seems to me that the installedboost lib 1.61 does not match the boost 1.61 source. I will try to install the lib manually and check if this solves the problem.

我更新为1.61,然后更新为1.62.问题仍然存在. 我检查了链接器命令,并确保该行的末尾存在"-lboost_regex". 我只能想到两个问题:

I updated to 1.61 and afterwards to 1.62. To problem remains. I checked my linker command and ensured that "-lboost_regex" is present at the end of the line. I can only think of two problems:

  1. 我的系统有一个旧的boost_regex库,尽管cmake宣布使用1.62,但cmake仍使用该库链接它.
  2. 更新标头时,Kali中的boost_regex库已过时.

我检查了我的图书馆,它们看起来不错:

I have checked my libraries and they seem to look good:

newgen@kali:/usr/lib/i386-linux-gnu$ ls -al | grep boost | grep regex
-rw-r--r--   1 root   root    2390702 Nov 12 19:46 libboost_regex.a
lrwxrwxrwx   1 root   root         24 Nov 12 19:46 libboost_regex.so -> libboost_regex.so.1.62.0
    -rw-r--r--   1 root   root    1107284 Nov 12 19:46 libboost_regex.so.1.62.0

更新:09.12.2016: 我没有导出共享对象,但是来自boost开发人员的提示指出了包装中的混乱.我试图查看当前的库,我猜想lib是v1.58,而标头是v1.62.

Update: 09.12.2016: I am no export on shared objects but a hint from the boost developers points to a mess up in the packaging. I tried to look into the current library and I would guess that the lib is v1.58 while the headers are v1.62.

/usr/lib/i386-linux-gnu$ nm --dynamic libboost_regex.so.1.62.0 | grep   regex_search

0005d4e0 W _ZN5boost12regex_searchINS_16re_detail_10620016mapfile_iteratorESaINS_9sub_matchIS2_EEEcNS_12regex_traitsIcNS_16cpp_regex_traitsIcEEEEEEbT_SA_RNS_13match_resultsISA_T0_EERKNS_11basic_regexIT1_T2_EENS_15regex_constants12_match_flagsE

在Kali Linux Bug Tracker中打开了一个Bug: https://bugs.kali.org/view.php?id=3765

Opened a Bug in the Kali Linux Bug Tracker: https://bugs.kali.org/view.php?id=3765

推荐答案

boost 1.61(及更高版本)是使用较新的编译器进行编译的,这些编译器使用_GLIBCXX_USE_CXX11_ABI = 1 .. heh ABI.这意味着-std = c ++ 11 std::basic_string...变为std::__cxx11::basic_string...(对于std :: list也是如此;参见

The boost 1.61 (and higher) are compiled with newer compilers, which use the _GLIBCXX_USE_CXX11_ABI=1 .. heh ABI. Meaning that for -std=c++11 std::basic_string... becomes std::__cxx11::basic_string... (and likewise for std::list; see the gcc Dual ABI documentation).

由于您的链接器错误声称缺少一个包含std::string的符号(它是std::basic_string<char,std::char_traits<char>,std::allocator<char>>的缩写),因此您正在使用过旧且使用ABI 0的编译器进行编译,或者您甚至在显式地进行编译与-D_GLIBCXX_USE_CXX11_ABI=0.

Since your linker error claims there is a missing symbol that contains std::string (which is short for std::basic_string<char,std::char_traits<char>,std::allocator<char>>), you are either compiling with a compiler that is too old and uses ABI 0, or you are even compiling explicitly with -D_GLIBCXX_USE_CXX11_ABI=0.

无论哪种方式,在您的CXXFLAGS中添加-D_GLIBCXX_USE_CXX11_ABI=1都可以解决问题.

Either way, adding -D_GLIBCXX_USE_CXX11_ABI=1 to your CXXFLAGS should solve the problem.

这篇关于regex_search.hpp:56:对`boost :: re_detail_106100 :: perl_matcher的未定义引用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆