Boost C++ Libraries: Ticket #12635: Strange undefined reference link errors for boost_regex https://svn.boost.org/trac10/ticket/12635 <p> Hi, </p> <p> 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. </p> <p> Here is the errors: <a class="missing wiki">MakeFiles</a>/myapp.dir/source/cornerAnal.cc.o: In function `CustomRandomMgr::nameMatchPattern(stlp_std::basic_string&lt;char, stlp_std::char_traits&lt;char&gt;, stlp_std::allocator&lt;char&gt; &gt; const&amp;, stlp_std::basic_string&lt;char, stlp_std::char_traits&lt;char&gt;, stlp_std::allocator&lt;char&gt; &gt; const&amp;)': cornerAnal.cc:(.text+0x5740): undefined reference to `boost::re_detail_106000::perl_matcher&lt;char const*, stlp_std::allocator&lt;boost::sub_match&lt;char const*&gt; &gt;, boost::regex_traits&lt;char, boost::cpp_regex_traits&lt;char&gt; &gt; &gt;::construct_init(boost::basic_regex&lt;char, boost::regex_traits&lt;char, boost::cpp_regex_traits&lt;char&gt; &gt; &gt; const&amp;, boost::regex_constants::_match_flags)' CMakeFiles/myapp.dir/source/cornerAnal.cc.o: In function `void boost::re_detail_106000::raise_error&lt;boost::regex_traits_wrapper&lt;boost::regex_traits&lt;char, boost::cpp_regex_traits&lt;char&gt; &gt; &gt; &gt;(boost::regex_traits_wrapper&lt;boost::regex_traits&lt;char, boost::cpp_regex_traits&lt;char&gt; &gt; &gt; const&amp;, 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&amp;)' CMakeFiles/myapp.dir/source/cornerAnal.cc.o: In function `boost::re_detail_106000::perl_matcher&lt;char const*, stlp_std::allocator&lt;boost::sub_match&lt;char const*&gt; &gt;, boost::regex_traits&lt;char, boost::cpp_regex_traits&lt;char&gt; &gt; &gt;::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&lt;char const*, stlp_std::allocator&lt;boost::sub_match&lt;char const*&gt; &gt; &gt;::maybe_assign(boost::match_results&lt;char const*, stlp_std::allocator&lt;boost::sub_match&lt;char const*&gt; &gt; &gt; const&amp;)' CMakeFiles/myapp.dir/source/cornerAnal.cc.o: In function `boost::re_detail_106000::perl_matcher&lt;char const*, stlp_std::allocator&lt;boost::sub_match&lt;char const*&gt; &gt;, boost::regex_traits&lt;char, boost::cpp_regex_traits&lt;char&gt; &gt; &gt;::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&lt;char const*, stlp_std::allocator&lt;boost::sub_match&lt;char const*&gt; &gt; &gt;::maybe_assign(boost::match_results&lt;char const*, stlp_std::allocator&lt;boost::sub_match&lt;char const*&gt; &gt; &gt; const&amp;)' CMakeFiles/myapp.dir/source/cornerAnal.cc.o: In function `bool boost::regex_search&lt;char const*, stlp_std::allocator&lt;boost::sub_match&lt;char const*&gt; &gt;, char, boost::regex_traits&lt;char, boost::cpp_regex_traits&lt;char&gt; &gt; &gt;(char const*, char const*, boost::match_results&lt;char const*, stlp_std::allocator&lt;boost::sub_match&lt;char const*&gt; &gt; &gt;&amp;, boost::basic_regex&lt;char, boost::regex_traits&lt;char, boost::cpp_regex_traits&lt;char&gt; &gt; &gt; const&amp;, 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&lt;char const*, stlp_std::allocator&lt;boost::sub_match&lt;char const*&gt; &gt;, boost::regex_traits&lt;char, boost::cpp_regex_traits&lt;char&gt; &gt; &gt;::construct_init(boost::basic_regex&lt;char, boost::regex_traits&lt;char, boost::cpp_regex_traits&lt;char&gt; &gt; &gt; const&amp;, boost::regex_constants::_match_flags)' CMakeFiles/myapp.dir/source/fftAnal.cc.o: In function `bool boost::regex_match&lt;char, boost::regex_traits&lt;char, boost::cpp_regex_traits&lt;char&gt; &gt; &gt;(char const*, boost::basic_regex&lt;char, boost::regex_traits&lt;char, boost::cpp_regex_traits&lt;char&gt; &gt; &gt; const&amp;, 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&lt;char const*, stlp_std::allocator&lt;boost::sub_match&lt;char const*&gt; &gt;, boost::regex_traits&lt;char, boost::cpp_regex_traits&lt;char&gt; &gt; &gt;::construct_init(boost::basic_regex&lt;char, boost::regex_traits&lt;char, boost::cpp_regex_traits&lt;char&gt; &gt; &gt; const&amp;, boost::regex_constants::_match_flags)' CMakeFiles/myapp.dir/source/waveformPostMeas.cc.o: In function `bool boost::regex_match&lt;char const*, stlp_std::allocator&lt;boost::sub_match&lt;char const*&gt; &gt;, char, boost::regex_traits&lt;char, boost::cpp_regex_traits&lt;char&gt; &gt; &gt;(char const*, char const*, boost::match_results&lt;char const*, stlp_std::allocator&lt;boost::sub_match&lt;char const*&gt; &gt; &gt;&amp;, boost::basic_regex&lt;char, boost::regex_traits&lt;char, boost::cpp_regex_traits&lt;char&gt; &gt; &gt; const&amp;, 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&lt;char const*, stlp_std::allocator&lt;boost::sub_match&lt;char const*&gt; &gt;, boost::regex_traits&lt;char, boost::cpp_regex_traits&lt;char&gt; &gt; &gt;::construct_init(boost::basic_regex&lt;char, boost::regex_traits&lt;char, boost::cpp_regex_traits&lt;char&gt; &gt; &gt; const&amp;, boost::regex_constants::_match_flags)' CMakeFiles/myapp.dir/source/analOutput.cc.o: In function `analOutput::extractSignalName(char const*, stlp_std::basic_string&lt;char, stlp_std::char_traits&lt;char&gt;, stlp_std::allocator&lt;char&gt; &gt;&amp;, stlp_std::basic_string&lt;char, stlp_std::char_traits&lt;char&gt;, stlp_std::allocator&lt;char&gt; &gt;&amp;, stlp_std::basic_string&lt;char, stlp_std::char_traits&lt;char&gt;, stlp_std::allocator&lt;char&gt; &gt;&amp;)': analOutput.cc:(.text+0x15fa3): undefined reference to `boost::re_detail_106000::perl_matcher&lt;char const*, stlp_std::allocator&lt;boost::sub_match&lt;char const*&gt; &gt;, boost::regex_traits&lt;char, boost::cpp_regex_traits&lt;char&gt; &gt; &gt;::construct_init(boost::basic_regex&lt;char, boost::regex_traits&lt;char, boost::cpp_regex_traits&lt;char&gt; &gt; &gt; const&amp;, 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&lt;char const*, stlp_std::allocator&lt;boost::sub_match&lt;char const*&gt; &gt;, boost::regex_traits&lt;char, boost::cpp_regex_traits&lt;char&gt; &gt; &gt;::construct_init(boost::basic_regex&lt;char, boost::regex_traits&lt;char, boost::cpp_regex_traits&lt;char&gt; &gt; &gt; const&amp;, 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&lt;char const*, stlp_std::allocator&lt;boost::sub_match&lt;char const*&gt; &gt;, boost::regex_traits&lt;char, boost::cpp_regex_traits&lt;char&gt; &gt; &gt;::construct_init(boost::basic_regex&lt;char, boost::regex_traits&lt;char, boost::cpp_regex_traits&lt;char&gt; &gt; &gt; const&amp;, boost::regex_constants::_match_flags)' follow </p> <p> Thanks, Shaohua </p> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/12635 Trac 1.4.3 John Maddock Sat, 03 Dec 2016 18:12:09 GMT <link>https://svn.boost.org/trac10/ticket/12635#comment:1 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/12635#comment:1</guid> <description> <p> What do you mean by "already added libboost_regex library"? </p> <p> The linker command -lboost_regex should appear *after* all of the object files which use Boost.Regex. </p> </description> <category>Ticket</category> </item> <item> <author>newgen23@…</author> <pubDate>Fri, 09 Dec 2016 16:04:48 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/12635#comment:2 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/12635#comment:2</guid> <description> <p> <a class="ext-link" href="http://stackoverflow.com/questions/40225571/regex-search-hpp56-undefined-reference-to-boostre-detail-106100perl-match"><span class="icon">​</span>http://stackoverflow.com/questions/40225571/regex-search-hpp56-undefined-reference-to-boostre-detail-106100perl-match</a> </p> <p> Same problem. </p> </description> <category>Ticket</category> </item> <item> <dc:creator>anonymous</dc:creator> <pubDate>Fri, 09 Dec 2016 19:50:22 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/12635#comment:3 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/12635#comment:3</guid> <description> <blockquote class="citation"> <p> <a class="ext-link" href="http://stackoverflow.com/questions/40225571/regex-search-hpp56-undefined-reference-to-boostre-detail-106100perl-match"><span class="icon">​</span>http://stackoverflow.com/questions/40225571/regex-search-hpp56-undefined-reference-to-boostre-detail-106100perl-match</a> </p> <p> Same problem. </p> </blockquote> <p> 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... </p> </description> <category>Ticket</category> </item> <item> <dc:creator>anonymous</dc:creator> <pubDate>Fri, 09 Dec 2016 20:06:07 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/12635#comment:4 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/12635#comment:4</guid> <description> <p> Replying to <a class="ticket" href="https://svn.boost.org/trac10/ticket/12635#comment:3" title="Comment 3">anonymous</a>: </p> <blockquote class="citation"> <blockquote class="citation"> <p> <a class="ext-link" href="http://stackoverflow.com/questions/40225571/regex-search-hpp56-undefined-reference-to-boostre-detail-106100perl-match"><span class="icon">​</span>http://stackoverflow.com/questions/40225571/regex-search-hpp56-undefined-reference-to-boostre-detail-106100perl-match</a> </p> <p> Same problem. </p> </blockquote> <p> 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... </p> </blockquote> <p> 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 ? </p> </description> <category>Ticket</category> </item> <item> <dc:creator>John Maddock</dc:creator> <pubDate>Sat, 10 Dec 2016 18:43:24 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/12635#comment:5 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/12635#comment:5</guid> <description> <p> Sorry I was a bit short and harsh: </p> <ul><li>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. </li><li>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 ;) </li><li>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. </li><li>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. </li><li>If in doubt you can see what symbols are exported from a library with "nm -gC libraryname.so" </li></ul> </description> <category>Ticket</category> </item> <item> <author>shaohua199@…</author> <pubDate>Tue, 03 Jan 2017 03:24:00 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/12635#comment:6 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/12635#comment:6</guid> <description> <p> Hi, </p> <p> This problem is resolved. </p> <p> After I use "nm -gC libboost_regex.so" command to check my library, I find the 0000000000051370 W boost::re_detail_106000::perl_matcher&lt;boost::re_detail_106000::mapfile_iterator, <strong>stl</strong>::allocator&lt;boost::sub_match&lt;boost::re_detail_106000::mapfile_iterator&gt; &gt;, boost::regex_traits&lt;char, boost::cpp_regex_traits&lt;char&gt; &gt; &gt;::construct_init(boost::basic_regex&lt;char, boost::regex_traits&lt;char, boost::cpp_regex_traits&lt;char&gt; &gt; &gt; const&amp;, boost::regex_constants::_match_flags) </p> <p> And my link error is: error: undefined reference to 'boost::re_detail_106000::perl_matcher&lt;char const*, <strong>stlp_std</strong>::allocator&lt;boost::sub_match&lt;char const*&gt; &gt;, boost::regex_traits&lt;char, boost::cpp_regex_traits&lt;char&gt; &gt; &gt;::construct_init(boost::basic_regex&lt;char, boost::regex_traits&lt;char, boost::cpp_regex_traits&lt;char&gt; &gt; &gt; const&amp;, boost::regex_constants::_match_flags)' </p> <p> 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. </p> <p> Thanks very much for your help. </p> <p> Thanks, Shaohua </p> </description> <category>Ticket</category> </item> <item> <dc:creator>John Maddock</dc:creator> <pubDate>Thu, 09 Feb 2017 19:10:08 GMT</pubDate> <title>status changed; resolution set https://svn.boost.org/trac10/ticket/12635#comment:7 https://svn.boost.org/trac10/ticket/12635#comment:7 <ul> <li><strong>status</strong> <span class="trac-field-old">new</span> → <span class="trac-field-new">closed</span> </li> <li><strong>resolution</strong> → <span class="trac-field-new">invalid</span> </li> </ul> Ticket