C++ regex_search.hpp:56:boost::re_detail_106100::perl_matcher的未定义引用

C++ regex_search.hpp:56:boost::re_detail_106100::perl_matcher的未定义引用,c++,regex,boost,C++,Regex,Boost,从boost 1.58更新到1.61后,链接失败,出现以下错误: 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 1.58更新到1.61后,链接失败,出现以下错误:

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)'
我搜索了boost的changelog,但没有找到任何可能导致cmake链接失败的特定内容。就像我说的:它与1.58完美配合

libboost-regex1.61.0是否已损坏,或者链接是否以某种方式发生了更改

更新日期:2016年11月14日: Boost的Changelog显示名称空间已从“re_detail”重命名为“Boost_REGEX_detail”

我使用的是Kali滚动版本,在我看来,已安装的boost lib 1.61与boost 1.61源代码不匹配。我将尝试手动安装lib,并检查这是否解决了问题

我更新到1.61,之后更新到1.62。问题依然存在。 我检查了我的linker命令,并确保“-lboost_regex”出现在行的末尾。 我只能想到两个问题:

  • 我的系统有一个旧的boost_regex库,cmake使用它来链接,尽管cmake宣布使用1.62
  • Kali中的boost_regex lib在更新标头时已过时
  • 我检查了我的图书馆,它们看起来不错:

    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
    
    更新日期:2016年12月9日: 我不是在共享对象上导出,但是boost开发人员的一个提示指出了打包中的混乱。我试图查看当前库,我猜lib是v1.58,而header是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跟踪器中打开了一个Bug: boost 1.61(及更高版本)是使用更新的编译器编译的,这些编译器使用_GLIBCXX_use_cx11_ABI=1。。嘿,阿比。这意味着for-std=c++11
    std::basic_string…
    将变成
    std::\uuuu cx11::basic_string…
    (同样,对于std::list,请参阅)

    由于链接器错误声明缺少包含
    std::string
    (它是
    std::basic_string
    的缩写)的符号,因此您要么使用太旧且使用ABI 0的编译器编译,要么甚至使用
    -D_GLIBCXX_USE_cx11_ABI=0
    显式编译

    无论采用哪种方式,在CXXFLAGS中添加
    -D\u GLIBCXX\u USE\u CXX11\u ABI=1
    都可以解决问题。

    他说的是对的。有时候,仍然需要检查一件事,那就是确保boost的编译器与调用程序相同。我在这方面犯了一个错误。我的linux包括不同路径的gcc版本4.8.5和gcc版本5.4.0,我的boost bz2使用旧版本,调用方caffe_ssd使用新版本。 我通过命令grep-rn gcc从
    boost\u 1\u 70\u 0/bin.v2/project cache.jam
    中找到了关键消息

    set“default address-model-32-bit-64-bit-linux-4.8.5gcc”:“5”

    并且,我检查了调用方的gcc版本;它是
    $CXX
    ,我的
    %CXX
    是5.4.0


    接下来,你知道我该怎么做;我使用gcc 5.4.0重新编译boost时遇到了同样的问题,我使用1.61头进行编译,链接器找到了1.58个libs,而不是新的1.61 libsApt get update;apt获得升级安装版本1.62。还是一样的问题。链接器在哪里找到1.58 libs?我想我把它们都删除了?看看是否有1.58个lib,名为libboost_regex.
    -我混合了1.58和1.61,当我重新命名1.58个lib时OK@newgen你能解决这个问题吗?我也有同样的问题!是的,我解决了这个问题。我下载、编译并安装了1.62版。然后,通过将手动安装的版本复制到kali fs中的位置,手动重写kali linux.so文件。我记不起我到底做了什么。然而,在这一过程之后,它起了作用。我现在检测到了版本1.62,并对其进行了编译。Kali libboost_regex.so.1.62.0肯定被破坏了,但是他们的支持在没有遵循我描述的步骤的情况下关闭了我的票据;用我在一个项目中使用的同一个编译器编译boost为我解决了这个问题。
    /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