Opened 6 years ago
Closed 6 years ago
#12635 closed Bugs (invalid)
Strange undefined reference link errors for boost_regex
Reported by: | Owned by: | John Maddock | |
---|---|---|---|
Milestone: | To Be Determined | Component: | regex |
Version: | Boost 1.60.0 | Severity: | Problem |
Keywords: | Cc: | shaohua199@… |
Description
Hi,
When I link boost library to my application, it will report lots of link errors, unless i have already added libboost_regex library. I am working on Centos6.7, gcc-4.8.4, 64bit.
Here is the errors: MakeFiles/myapp.dir/source/cornerAnal.cc.o: In function `CustomRandomMgr::nameMatchPattern(stlp_std::basic_string<char, stlp_std::char_traits<char>, stlp_std::allocator<char> > const&, stlp_std::basic_string<char, stlp_std::char_traits<char>, stlp_std::allocator<char> > const&)': cornerAnal.cc:(.text+0x5740): undefined reference to `boost::re_detail_106000::perl_matcher<char const*, stlp_std::allocator<boost::sub_match<char const*> >, 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)' CMakeFiles/myapp.dir/source/cornerAnal.cc.o: In function `void boost::re_detail_106000::raise_error<boost::regex_traits_wrapper<boost::regex_traits<char, boost::cpp_regex_traits<char> > > >(boost::regex_traits_wrapper<boost::regex_traits<char, boost::cpp_regex_traits<char> > > const&, boost::regex_constants::error_type)': cornerAnal.cc:(.text._ZN5boost16re_detail_10600011raise_errorINS_20regex_traits_wrapperINS_12regex_traitsIcNS_16cpp_regex_traitsIcEEEEEEEEvRKT_NS_15regex_constants10error_typeE[_ZN5boost16re_detail_10600011raise_errorINS_20regex_traits_wrapperINS_12regex_traitsIcNS_16cpp_regex_traitsIcEEEEEEEEvRKT_NS_15regex_constants10error_typeE]+0x98): undefined reference to `boost::re_detail_106000::raise_runtime_error(stlp_std::runtime_error const&)' CMakeFiles/myapp.dir/source/cornerAnal.cc.o: In function `boost::re_detail_106000::perl_matcher<char const*, stlp_std::allocator<boost::sub_match<char const*> >, boost::regex_traits<char, boost::cpp_regex_traits<char> > >::match_prefix()': cornerAnal.cc:(.text._ZN5boost16re_detail_10600012perl_matcherIPKcN8stlp_std9allocatorINS_9sub_matchIS3_EEEENS_12regex_traitsIcNS_16cpp_regex_traitsIcEEEEE12match_prefixEv[_ZN5boost16re_detail_10600012perl_matcherIPKcN8stlp_std9allocatorINS_9sub_matchIS3_EEEENS_12regex_traitsIcNS_16cpp_regex_traitsIcEEEEE12match_prefixEv]+0x110): undefined reference to `boost::match_results<char const*, stlp_std::allocator<boost::sub_match<char const*> > >::maybe_assign(boost::match_results<char const*, stlp_std::allocator<boost::sub_match<char const*> > > const&)' CMakeFiles/myapp.dir/source/cornerAnal.cc.o: In function `boost::re_detail_106000::perl_matcher<char const*, stlp_std::allocator<boost::sub_match<char const*> >, boost::regex_traits<char, boost::cpp_regex_traits<char> > >::match_match()': cornerAnal.cc:(.text._ZN5boost16re_detail_10600012perl_matcherIPKcN8stlp_std9allocatorINS_9sub_matchIS3_EEEENS_12regex_traitsIcNS_16cpp_regex_traitsIcEEEEE11match_matchEv[_ZN5boost16re_detail_10600012perl_matcherIPKcN8stlp_std9allocatorINS_9sub_matchIS3_EEEENS_12regex_traitsIcNS_16cpp_regex_traitsIcEEEEE11match_matchEv]+0x33f): undefined reference to `boost::match_results<char const*, stlp_std::allocator<boost::sub_match<char const*> > >::maybe_assign(boost::match_results<char const*, stlp_std::allocator<boost::sub_match<char const*> > > const&)' CMakeFiles/myapp.dir/source/cornerAnal.cc.o: In function `bool boost::regex_search<char const*, stlp_std::allocator<boost::sub_match<char const*> >, char, boost::regex_traits<char, boost::cpp_regex_traits<char> > >(char const*, char const*, boost::match_results<char const*, stlp_std::allocator<boost::sub_match<char const*> > >&, boost::basic_regex<char, boost::regex_traits<char, boost::cpp_regex_traits<char> > > const&, boost::regex_constants::_match_flags, char const*)': cornerAnal.cc:(.text._ZN5boost12regex_searchIPKcN8stlp_std9allocatorINS_9sub_matchIS2_EEEEcNS_12regex_traitsIcNS_16cpp_regex_traitsIcEEEEEEbT_SC_RNS_13match_resultsISC_T0_EERKNS_11basic_regexIT1_T2_EENS_15regex_constants12_match_flagsESC_[_ZN5boost12regex_searchIPKcN8stlp_std9allocatorINS_9sub_matchIS2_EEEEcNS_12regex_traitsIcNS_16cpp_regex_traitsIcEEEEEEbT_SC_RNS_13match_resultsISC_T0_EERKNS_11basic_regexIT1_T2_EENS_15regex_constants12_match_flagsESC_]+0xf7): undefined reference to `boost::re_detail_106000::perl_matcher<char const*, stlp_std::allocator<boost::sub_match<char const*> >, 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)' CMakeFiles/myapp.dir/source/fftAnal.cc.o: In function `bool boost::regex_match<char, boost::regex_traits<char, boost::cpp_regex_traits<char> > >(char const*, boost::basic_regex<char, boost::regex_traits<char, boost::cpp_regex_traits<char> > > const&, boost::regex_constants::_match_flags)': fftAnal.cc:(.text._ZN5boost11regex_matchIcNS_12regex_traitsIcNS_16cpp_regex_traitsIcEEEEEEbPKT_RKNS_11basic_regexIS5_T0_EENS_15regex_constants12_match_flagsE[_ZN5boost11regex_matchIcNS_12regex_traitsIcNS_16cpp_regex_traitsIcEEEEEEbPKT_RKNS_11basic_regexIS5_T0_EENS_15regex_constants12_match_flagsE]+0x13c): undefined reference to `boost::re_detail_106000::perl_matcher<char const*, stlp_std::allocator<boost::sub_match<char const*> >, 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)' CMakeFiles/myapp.dir/source/waveformPostMeas.cc.o: In function `bool boost::regex_match<char const*, stlp_std::allocator<boost::sub_match<char const*> >, char, boost::regex_traits<char, boost::cpp_regex_traits<char> > >(char const*, char const*, boost::match_results<char const*, stlp_std::allocator<boost::sub_match<char const*> > >&, boost::basic_regex<char, boost::regex_traits<char, boost::cpp_regex_traits<char> > > const&, boost::regex_constants::_match_flags)': waveformPostMeas.cc:(.text._ZN5boost11regex_matchIPKcN8stlp_std9allocatorINS_9sub_matchIS2_EEEEcNS_12regex_traitsIcNS_16cpp_regex_traitsIcEEEEEEbT_SC_RNS_13match_resultsISC_T0_EERKNS_11basic_regexIT1_T2_EENS_15regex_constants12_match_flagsE[_ZN5boost11regex_matchIPKcN8stlp_std9allocatorINS_9sub_matchIS2_EEEEcNS_12regex_traitsIcNS_16cpp_regex_traitsIcEEEEEEbT_SC_RNS_13match_resultsISC_T0_EERKNS_11basic_regexIT1_T2_EENS_15regex_constants12_match_flagsE]+0xcb): undefined reference to `boost::re_detail_106000::perl_matcher<char const*, stlp_std::allocator<boost::sub_match<char const*> >, 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)' CMakeFiles/myapp.dir/source/analOutput.cc.o: In function `analOutput::extractSignalName(char const*, stlp_std::basic_string<char, stlp_std::char_traits<char>, stlp_std::allocator<char> >&, stlp_std::basic_string<char, stlp_std::char_traits<char>, stlp_std::allocator<char> >&, stlp_std::basic_string<char, stlp_std::char_traits<char>, stlp_std::allocator<char> >&)': analOutput.cc:(.text+0x15fa3): undefined reference to `boost::re_detail_106000::perl_matcher<char const*, stlp_std::allocator<boost::sub_match<char const*> >, 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)' ../kernelCommon/dist/Release_64/GNU-Linux-x86/libkernelcommon.a(Kernel.cc.o): In function `Kernel::checkNoFilterByName(char const*, int)': Kernel.cc:(.text+0x16686): undefined reference to `boost::re_detail_106000::perl_matcher<char const*, stlp_std::allocator<boost::sub_match<char const*> >, 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)' ../kernelCommon/dist/Release_64/GNU-Linux-x86/libkernelcommon.a(kdbNodeBox.cc.o):kdbNodeBox.cc:(.text+0x51757): more undefined references to `boost::re_detail_106000::perl_matcher<char const*, stlp_std::allocator<boost::sub_match<char const*> >, 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)' follow
Thanks, Shaohua
Change History (7)
comment:1 by , 6 years ago
comment:2 by , 6 years ago
follow-up: 4 comment:3 by , 6 years ago
Same problem.
Nope, that's a different issue - that issue is caused by compiling against headers from one version and linking to a library from a different version. That's not supported and never has been, it's just that the issue is caught now. It's also not our problem but a packaging issue somewhere downstream...
comment:4 by , 6 years ago
Replying to anonymous:
Same problem.
Nope, that's a different issue - that issue is caused by compiling against headers from one version and linking to a library from a different version. That's not supported and never has been, it's just that the issue is caught now. It's also not our problem but a packaging issue somewhere downstream...
A packaging issue downstream? For Version 1.60, 1.61 and 1.62 ? Is there any way to find out whats inside /usr/lib/i386-linux-gnu/libboost_regex.so.1.60.0 ?
comment:5 by , 6 years ago
Sorry I was a bit short and harsh:
- Boost has never supported binary compatibility between releases, if you compile against one versions headers and link to another versions .so file, bad stuff will happen somewhere down the road.
- Recent Boost.Regex releases have enforced this by mangling their namespace with the Boost version number - the only difference from previous releases is that now you're prevented from shooting yourself in the foot quite so often ;)
- If you just specify -lboost_regex on the command line, you will presumably link against whatever version was installed by the official system package. Use the "file" command to discover where libboost_regex.so points.
- If you manually install a later version, or use a package someone has prepared, then there are a whole host of possible build options that are outside our control - in particular they may install the binaries in a location not searched by default (such as /usr/local/lib), but you will need to consult the package builders own documentation on this. You may also need to link against a specific version if the libboost_regex symlink has not been over-written.
- If in doubt you can see what symbols are exported from a library with "nm -gC libraryname.so"
comment:6 by , 6 years ago
Hi,
This problem is resolved.
After I use "nm -gC libboost_regex.so" command to check my library, I find the 0000000000051370 W boost::re_detail_106000::perl_matcher<boost::re_detail_106000::mapfile_iterator, stl::allocator<boost::sub_match<boost::re_detail_106000::mapfile_iterator> >, 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)
And my link error is: error: undefined reference to 'boost::re_detail_106000::perl_matcher<char const*, stlp_std::allocator<boost::sub_match<char const*> >, 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)'
So it is caused by my application use stlport library. After I re-compile boost library with "stdlib=stlport" option and specified "using stlport" in project-config.jam file, the link process is OK now.
Thanks very much for your help.
Thanks, Shaohua
comment:7 by , 6 years ago
Resolution: | → invalid |
---|---|
Status: | new → closed |
What do you mean by "already added libboost_regex library"?
The linker command -lboost_regex should appear *after* all of the object files which use Boost.Regex.