1

The below code is compiled successfully with GCC 4.9.2 without any warning:

#include <memory>
#include <string>
#include <boost/regex.hpp>

int main()
{
boost::wregex wregex;
std::wstring text = L"foobar";
return boost::regex_match(text, wregex);
}

command run is:

g++ -I /opt/boost/x86_64/1.60.0/include -L /opt/boost/x86_64/1.60.0/lib test.cc  -lboost_regex

but shows the following error when used with GCC 5.2.0:

/tmp/cc3L5WWc.o: In function `bool boost::regex_match<__gnu_cxx::__normal_iterator<wchar_t const*, std::__cxx11::basic_string<wchar_t, std::char_traits<wchar_t>, std::allocator<wchar_t> > >, std::allocator<boost::sub_match<__gnu_cxx::__normal_iterator<wchar_t const*, std::__cxx11::basic_string<wchar_t, std::char_traits<wchar_t>, std::allocator<wchar_t> > > > >, wchar_t, boost::regex_traits<wchar_t, boost::cpp_regex_traits<wchar_t> > >(__gnu_cxx::__normal_iterator<wchar_t const*, std::__cxx11::basic_string<wchar_t, std::char_traits<wchar_t>, std::allocator<wchar_t> > >, __gnu_cxx::__normal_iterator<wchar_t const*, std::__cxx11::basic_string<wchar_t, std::char_traits<wchar_t>, std::allocator<wchar_t> > >, boost::match_results<__gnu_cxx::__normal_iterator<wchar_t const*, std::__cxx11::basic_string<wchar_t, std::char_traits<wchar_t>, std::allocator<wchar_t> > >, std::allocator<boost::sub_match<__gnu_cxx::__normal_iterator<wchar_t const*, std::__cxx11::basic_string<wchar_t, std::char_traits<wchar_t>, std::allocator<wchar_t> > > > > >&, boost::basic_regex<wchar_t, boost::regex_traits<wchar_t, boost::cpp_regex_traits<wchar_t> > > const&, boost::regex_constants::_match_flags)': test.cc:(.text._ZN5boost11regex_matchIN9__gnu_cxx17__normal_iteratorIPKwNSt7__cxx1112basic_stringIwSt11char_traitsIwESaIwEEEEESaINS_9sub_matchISB_EEEwNS_12regex_traitsIwNS_16cpp_regex_traitsIwEEEEEEbT_SJ_RNS_13match_resultsISJ_T0_EERKNS_11basic_regexIT1_T2_EENS_15regex_constants12_match_flagsE[_ZN5boost11regex_matchIN9__gnu_cxx17__normal_iteratorIPKwNSt7__cxx1112basic_stringIwSt11char_traitsIwESaIwEEEEESaINS_9sub_matchISB_EEEwNS_12regex_traitsIwNS_16cpp_regex_traitsIwEEEEEEbT_SJ_RNS_13match_resultsISJ_T0_EERKNS_11basic_regexIT1_T2_EENS_15regex_constants12_match_flagsE]+0x80): undefined reference to `boost::re_detail_106000::perl_matcher<__gnu_cxx::__normal_iterator<wchar_t const*, std::__cxx11::basic_string<wchar_t, std::char_traits<wchar_t>, std::allocator<wchar_t> > >, std::allocator<boost::sub_match<__gnu_cxx::__normal_iterator<wchar_t const*, std::__cxx11::basic_string<wchar_t, std::char_traits<wchar_t>, std::allocator<wchar_t> > > > >, boost::regex_traits<wchar_t, boost::cpp_regex_traits<wchar_t> > >::match()'/tmp/cc3L5WWc.o: In function `boost::re_detail_106000::perl_matcher<__gnu_cxx::__normal_iterator<wchar_t const*, std::__cxx11::basic_string<wchar_t, std::char_traits<wchar_t>, std::allocator<wchar_t> > >, std::allocator<boost::sub_match<__gnu_cxx::__normal_iterator<wchar_t const*, std::__cxx11::basic_string<wchar_t, std::char_traits<wchar_t>, std::allocator<wchar_t> > > > >, boost::regex_traits<wchar_t, boost::cpp_regex_traits<wchar_t> > >::perl_matcher(__gnu_cxx::__normal_iterator<wchar_t const*, std::__cxx11::basic_string<wchar_t, std::char_traits<wchar_t>, std::allocator<wchar_t> > >, __gnu_cxx::__normal_iterator<wchar_t const*, std::__cxx11::basic_string<wchar_t, std::char_traits<wchar_t>, std::allocator<wchar_t> > >, boost::match_results<__gnu_cxx::__normal_iterator<wchar_t const*, std::__cxx11::basic_string<wchar_t, std::char_traits<wchar_t>, std::allocator<wchar_t> > >, std::allocator<boost::sub_match<__gnu_cxx::__normal_iterator<wchar_t const*, std::__cxx11::basic_string<wchar_t, std::char_traits<wchar_t>, std::allocator<wchar_t> > > > > >&, boost::basic_regex<wchar_t, boost::regex_traits<wchar_t, boost::cpp_regex_traits<wchar_t> > > const&, boost::regex_constants::_match_flags, __gnu_cxx::__normal_iterator<wchar_t const*, std::__cxx11::basic_string<wchar_t, std::char_traits<wchar_t>, std::allocator<wchar_t> > >)': 
 test.cc:(.text._ZN5boost16re_detail_10600012perl_matcherIN9__gnu_cxx17__normal_iteratorIPKwNSt7__cxx1112basic_stringIwSt11char_traitsIwESaIwEEEEESaINS_9sub_matchISC_EEENS_12regex_traitsIwNS_16cpp_regex_traitsIwEEEEEC2ESC_SC_RNS_13match_resultsISC_SF_EERKNS_11basic_regexIwSJ_EENS_15regex_constants12_match_flagsESC_[_ZN5boost16re_detail_10600012perl_matcherIN9__gnu_cxx17__normal_iteratorIPKwNSt7__cxx1112basic_stringIwSt11char_traitsIwESaIwEEEEESaINS_9sub_matchISC_EEENS_12regex_traitsIwNS_16cpp_regex_traitsIwEEEEEC5ESC_SC_RNS_13match_resultsISC_SF_EERKNS_11basic_regexIwSJ_EENS_15regex_constants12_match_flagsESC_]+0x116): undefined reference to `boost::re_detail_106000::perl_matcher<__gnu_cxx::__normal_iterator<wchar_t const*, std::__cxx11::basic_string<wchar_t, std::char_traits<wchar_t>, std::allocator<wchar_t> > >, std::allocator<boost::sub_match<__gnu_cxx::__normal_iterator<wchar_t const*, std::__cxx11::basic_string<wchar_t, std::char_traits<wchar_t>, std::allocator<wchar_t> > > > >, boost::regex_traits<wchar_t, boost::cpp_regex_traits<wchar_t> > >::construct_init(boost::basic_regex<wchar_t, boost::regex_traits<wchar_t, boost::cpp_regex_traits<wchar_t> > > const&, boost::regex_constants::_match_flags)'
 collect2: error: ld returned 1 exit status
einpoklum
  • 118,144
  • 57
  • 340
  • 684
Emlyn Jose
  • 19
  • 4
  • Have you tried to add the option -std=c++14 ( I found it here : https://solarianprogrammer.com/2016/03/06/compiling-boost-gcc-5-clang-mac-os-x/ ) – KimKulling Apr 08 '16 at 07:24
  • yes i checked this page. but that didn't work. thank you! – Emlyn Jose Apr 08 '16 at 08:15
  • ok, and is your boost-version (1.60 ) ABI-compatible to gcc 5.2.0 or do you have to install a new boost version? – KimKulling Apr 08 '16 at 10:49
  • Sorry, i am not familiar with ABI. How should i check if my boost version is ABI-compatible to gcc 5.2.0? – Emlyn Jose Apr 11 '16 at 04:19
  • I read about this ABI and built boost 1.60.0 by adding the macro as below: ./bootstrap.sh ./bjam -j4 define=_GLIBCXX_USE_CXX11_ABI=0 stage But even then there is no change. Is this the right way to do? By the way, i manually tried this by running g++ as below and it worked without fail: g++ -I /opt/boost/x86_64/1.60.0/include -L /opt/boost/x86_64/1.60.0/lib test.cc -D_GLIBCXX_USE_CXX11_ABI=0 -lboost_regex any other change to be done while building boost? – Emlyn Jose Apr 11 '16 at 08:18
  • YOu could just rebuild boost with your version of g++. – KimKulling Apr 11 '16 at 14:40
  • Did you eventually solve/circumvent this issue? – einpoklum Jan 27 '17 at 15:09

0 Answers0