Installed boost::regex, and it compiles, but can't get it to link
I am running ubuntu 9.04 I have built the libs from 1.39.0 with gcc 4.3 and moved them to /usr/local/boost I have done a $ sudo ldconfig -v and have seen the boost libaries are installed here is the code, taken from the boost web site: #include <boost/regex.hpp> #include <iostream> #include <string> using namespace std; int main() { string line; boost::regex pat( "^Subject: (Re: |Aw: )*(.*)" ); while (cin) { getline(cin, line); boost::smatch matches; if (boost::regex_match(line, matches, pat)) cout << matches[2] << endl; } } I can compile ok: g++ -I /usr/local/boost/include/boost-1_39 -c regex_example.cpp But when I try to link I get a ton of errors, can anyone tell me what I need to do next? -- Jerry $ g++ -I /usr/local/boost/include/boost-1_39 -L /usr/local/boost/lib regex_example.cpp /tmp/ccBBRJVR.o: In function `boost::basic_regex<char, boost::regex_traits<char, boost::cpp_regex_traits<char> > >::assign(char const*, char const*, unsigned int)': regex_example.cpp:(.text._ZN5boost11basic_regexIcNS_12regex_traitsIcNS_16cpp_regex_traitsIcEEEEE6assignEPKcS7_j[boost::basic_regex<char, boost::regex_traits<char, boost::cpp_regex_traits<char> > >::assign(char const*, char const*, unsigned int)]+0x22): undefined reference to `boost::basic_regex<char, boost::regex_traits<char, boost::cpp_regex_traits<char> > >::do_assign(char const*, char const*, unsigned int)' /tmp/ccBBRJVR.o: In function `boost::re_detail::perl_matcher<__gnu_cxx::__normal_iterator<char const*, std::basic_string<char, std::char_traits<char>, std::allocator<char> > >, std::allocator<boost::sub_match<__gnu_cxx::__normal_iterator<char const*, std::basic_string<char, std::char_traits<char>, std::allocator<char> > > > >, boost::regex_traits<char, boost::cpp_regex_traits<char> >
::perl_matcher(__gnu_cxx::__normal_iterator<char const*, std::basic_string<char, std::char_traits<char>, std::allocator<char> > >, __gnu_cxx::__normal_iterator<char const*, std::basic_string<char, std::char_traits<char>, std::allocator<char> > >, boost::match_results<__gnu_cxx::__normal_iterator<char const*, std::basic_string<char, std::char_traits<char>, std::allocator<char> > >, std::allocator<boost::sub_match<__gnu_cxx::__normal_iterator<char const*, std::basic_string<char, std::char_traits<char>, std::allocator<char> > > > >
&, 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::basic_string<char, std::char_traits<char>, std::allocator<char>
)': regex_example.cpp:(.text._ZN5boost9re_detail12perl_matcherIN9__gnu_cxx17__normal_iteratorIPKcSsEESaINS_9sub_matchIS6_EEENS_12regex_traitsIcNS_16cpp_regex_traitsIcEEEEEC1ES6_S6_RNS_13match_resultsIS6_S9_EERKNS_11basic_regexIcSD_EENS_15regex_constants12_match_flagsES6_[boost::re_detail::perl_matcher<__gnu_cxx::__normal_iterator<char const*, std::basic_string<char, std::char_traits<char>, std::allocator<char> > >, std::allocator<boost::sub_match<__gnu_cxx::__normal_iterator<char const*, std::basic_string<char, std::char_traits<char>, std::allocator<char> > > >
, boost::regex_traits<char, boost::cpp_regex_traits<char> >
::perl_matcher(__gnu_cxx::__normal_iterator<char const*, std::basic_string<char, std::char_traits<char>, std::allocator<char> > >, __gnu_cxx::__normal_iterator<char const*, std::basic_string<char, >std::char_traits<char>, std::allocator<char> > >, >boost::match_results<__gnu_cxx::__normal_iterator<char const*, >std::basic_string<char, std::char_traits<char>, std::allocator<char> > >>, std::allocator<boost::sub_match<__gnu_cxx::__normal_iterator<char >>const*, std::basic_string<char, std::char_traits<char>, >>std::allocator<char> > > > > >&, 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::basic_string<char, >>std::char_traits<char>, std::allocator<char> > >)]+0xc2): undefined >>reference to >>`boost::re_detail::perl_matcher<__gnu_cxx::__normal_iterator<char >>const*, std::basic_string<char, std::char_traits<char>, >>std::allocator<char> > >, >>std::allocator<boost::sub_match<__gnu_cxx::__normal_iterator<char >>const*, std::basic_string<char, std::char_traits<char>, >>std::allocator<char> > > > >, 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)' /tmp/ccBBRJVR.o: In function >>>`bool boost::regex_match<__gnu_cxx::__normal_iterator<char const*, >>>std::basic_string<char, std::char_traits<char>, std::allocator<char> >>>> >, >>>> >std::allocator<boost::sub_match<__gnu_cxx::__normal_iterator<char >>>> >const*, std::basic_string<char, std::char_traits<char>, >>>> >std::allocator<char> > > > >, char, boost::regex_traits<char, >>>> >boost::cpp_regex_traits<char> > >>>> >>(__gnu_cxx::__normal_iterator<char const*, >>>> >>std::basic_string<char, std::char_traits<char>, >>>> >>std::allocator<char> > >, __gnu_cxx::__normal_iterator<char >>>> >>const*, std::basic_string<char, std::char_traits<char>, >>>> >>std::allocator<char> > >, >>>> >>boost::match_results<__gnu_cxx::__normal_iterator<char const*, >>>> >>std::basic_string<char, std::char_traits<char>, >>>> >>std::allocator<char> > >, >>>> >>std::allocator<boost::sub_match<__gnu_cxx::__normal_iterator<char >>>> >>const*, std::basic_string<char, std::char_traits<char>, >>>> >>std::allocator<char> > > > > >&, boost::basic_regex<char, >>>> >>boost::regex_traits<char, boost::cpp_regex_traits<char> > > >>>> >>const&, boost::regex_constants::_match_flags)': >>>> >>regex_example.cpp:(.text._ZN5boost11regex_matchIN9__gnu_cxx17__normal_iteratorIPKcSsEESaINS_9sub_matchIS5_EEEcNS_12regex_traitsIcNS_16cpp_regex_traitsIcEEEEEEbT_SD_RNS_13match_resultsISD_T0_EERKNS_11basic_regexIT1_T2_EENS_15regex_constants12_match_flagsE[bool >>>> >>boost::regex_match<__gnu_cxx::__normal_iterator<char const*, >>>> >>std::basic_string<char, std::char_traits<char>, >>>> >>std::allocator<char> > >, >>>> >>std::allocator<boost::sub_match<__gnu_cxx::__normal_iterator<char >>>> >>const*, std::basic_string<char, std::char_traits<char>, >>>> >>std::allocator<char> > > > >, char, boost::regex_traits<char, >>>> >>boost::cpp_regex_traits<char> > >>>> >>>(__gnu_cxx::__normal_iterator<char const*, >>>> >>>std::basic_string<char, std::char_traits<char>, >>>> >>>std::allocator<char> > >, __gnu_cxx::__normal_iterator<char >>>> >>>const*, std::basic_string<char, std::char_traits<char>, >>>> >>>std::allocator<char> > >, >>>> >>>boost::match_results<__gnu_cxx::__normal_iterator<char const*, >>>> >>>std::basic_string<char, std::char_traits<char>, >>>> >>>std::allocator<char> > >, >>>> >>>std::allocator<boost::sub_match<__gnu_cxx::__normal_iterator<char >>>> >>>const*, std::basic_string<char, std::char_traits<char>, >>>> >>>std::allocator<char> > > > > >&, boost::basic_regex<char, >>>> >>>boost::regex_traits<char, boost::cpp_regex_traits<char> > > >>>> >>>const&, boost::regex_constants::_match_flags)]+0x47): undefined >>>> >>>reference to >>>> >>>`boost::re_detail::perl_matcher<__gnu_cxx::__normal_iterator<char >>>> >>>const*, std::basic_string<char, std::char_traits<char>, >>>> >>>std::allocator<char> > >, >>>> >>>std::allocator<boost::sub_match<__gnu_cxx::__normal_iterator<char >>>> >>>const*, std::basic_string<char, std::char_traits<char>, >>>> >>>std::allocator<char> > > > >, boost::regex_traits<char, >>>> >>>boost::cpp_regex_traits<char> > >::match()' /tmp/ccBBRJVR.o: In >>>> >>>function `boost::cpp_regex_traits<char>::transform(char const*, >>>> >>>char const*) const': >>>> >>>regex_example.cpp:(.text._ZNK5boost16cpp_regex_traitsIcE9transformEPKcS3_[boost::cpp_regex_traits<char>::transform(char >>>> >>>const*, char const*) const]+0x30): undefined reference to >>>> >>>`boost::re_detail::cpp_regex_traits_implementation<char>::transform(char >>>> >>>const*, char const*) const' /tmp/ccBBRJVR.o: In function >>>> >>>`boost::cpp_regex_traits<char>::transform_primary(char const*, >>>> >>>char const*) const': >>>> >>>regex_example.cpp:(.text._ZNK5boost16cpp_regex_traitsIcE17transform_primaryEPKcS3_[boost::cpp_regex_traits<char>::transform_primary(char >>>> >>>const*, char const*) const]+0x30): undefined reference to >>>> >>>`boost::re_detail::cpp_regex_traits_implementation<char>::transform_primary(char >>>> >>>const*, char const*) const' /tmp/ccBBRJVR.o: In function >>>> >>>`boost::re_detail::perl_matcher<__gnu_cxx::__normal_iterator<char >>>> >>>const*, std::basic_string<char, std::char_traits<char>, >>>> >>>std::allocator<char> > >, >>>> >>>std::allocator<boost::sub_match<__gnu_cxx::__normal_iterator<char >>>> >>>const*, std::basic_string<char, std::char_traits<char>, >>>> >>>std::allocator<char> > > > >, boost::regex_traits<char, >>>> >>>boost::cpp_regex_traits<char> > >::match_match()': >>>> >>>regex_example.cpp:(.text._ZN5boost9re_detail12perl_matcherIN9__gnu_cxx17__normal_iteratorIPKcSsEESaINS_9sub_matchIS6_EEENS_12regex_traitsIcNS_16cpp_regex_traitsIcEEEEE11match_matchEv[boost::re_detail::perl_matcher<__gnu_cxx::__normal_iterator<char >>>> >>>const*, std::basic_string<char, std::char_traits<char>, >>>> >>>std::allocator<char> > >, >>>> >>>std::allocator<boost::sub_match<__gnu_cxx::__normal_iterator<char >>>> >>>const*, std::basic_string<char, std::char_traits<char>, >>>> >>>std::allocator<char> > > > >, boost::regex_traits<char, >>>> >>>boost::cpp_regex_traits<char> > >::match_match()]+0x172): >>>> >>>undefined reference to >>>> >>>`boost::match_results<__gnu_cxx::__normal_iterator<char const*, >>>> >>>std::basic_string<char, std::char_traits<char>, >>>> >>>std::allocator<char> > >, >>>> >>>std::allocator<boost::sub_match<__gnu_cxx::__normal_iterator<char >>>> >>>const*, std::basic_string<char, std::char_traits<char>, >>>> >>>std::allocator<char> > > > > >>>> >>>>::maybe_assign(boost::match_results<__gnu_cxx::__normal_iterator<char >>>> >>>>const*, std::basic_string<char, std::char_traits<char>, >>>> >>>>std::allocator<char> > >, >>>> >>>>std::allocator<boost::sub_match<__gnu_cxx::__normal_iterator<char >>>> >>>>const*, std::basic_string<char, std::char_traits<char>, >>>> >>>>std::allocator<char> > > > > > const&)' /tmp/ccBBRJVR.o: In >>>> >>>>function >>>> >>>>`boost::re_detail::cpp_regex_traits_implementation<char>::error_string(boost::regex_constants::error_type) >>>> >>>>const': >>>> >>>>regex_example.cpp:(.text._ZNK5boost9re_detail31cpp_regex_traits_implementationIcE12error_stringENS_15regex_constants10error_typeE[boost::re_detail::cpp_regex_traits_implementation<char>::error_string(boost::regex_constants::error_type) >>>> >>>>const]+0x9b): undefined reference to >>>> >>>>`boost::re_detail::get_default_error_string(boost::regex_constants::error_type)' >>>> >>>>regex_example.cpp:(.text._ZNK5boost9re_detail31cpp_regex_traits_implementationIcE12error_stringENS_15regex_constants10error_typeE[boost::re_detail::cpp_regex_traits_implementation<char>::error_string(boost::regex_constants::error_type) >>>> >>>>const]+0x140): undefined reference to >>>> >>>>`boost::re_detail::get_default_error_string(boost::regex_constants::error_type)' /tmp/ccBBRJVR.o: >>>> >>>>In function `void >>>> >>>>boost::re_detail::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)': regex_example.cpp:(.text._ZN5boost9re_detail11raise_errorINS_20regex_traits_wrapperINS_12regex_traitsIcNS_16cpp_regex_traitsIcEEEEEEEEvRKT_NS_15regex_constants10error_typeE[void boost::re_detail::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)]+0x72): undefined reference to `boost::re_detail::raise_runtime_error(std::runtime_error const&)' /tmp/ccBBRJVR.o: In function `boost::re_detail::perl_matcher<__gnu_cxx::__normal_iterator<char const*, std::basic_string<char, std::char_traits<char>, std::allocator<char> > >, std::allocator<boost::sub_match<__gnu_cxx::__normal_iterator<char const*, std::basic_string<char, std::char_traits<char>, std::allocator<char> > > > >, boost::regex_traits<char, boost::cpp_regex_traits<char> > >::extend_stack()': regex_example.cpp:(.text._ZN5boost9re_detail12perl_matcherIN9__gnu_cxx17__normal_iteratorIPKcSsEESaINS_9sub_matchIS6_EEENS_12regex_traitsIcNS_16cpp_regex_traitsIcEEEEE12extend_stackEv[boost::re_detail::perl_matcher<__gnu_cxx::__normal_iterator<char const*, std::basic_string<char, std::char_traits<char>, std::allocator<char> > , std::allocator<boost::sub_match<__gnu_cxx::__normal_iterator<char const*, std::basic_string<char, std::char_traits<char>, std::allocator<char> > > > >, boost::regex_traits<char, boost::cpp_regex_traits<char> > ::extend_stack()]+0x20): undefined reference to `boost::re_detail::get_mem_block()' /tmp/ccBBRJVR.o: In function `boost::re_detail::perl_matcher<__gnu_cxx::__normal_iterator<char const*, std::basic_string<char, std::char_traits<char>, std::allocator<char> > >, std::allocator<boost::sub_match<__gnu_cxx::__normal_iterator<char const*, std::basic_string<char, std::char_traits<char>, std::allocator<char> > > > , boost::regex_traits<char, boost::cpp_regex_traits<char> > ::unwind_extra_block(bool)': regex_example.cpp:(.text._ZN5boost9re_detail12perl_matcherIN9__gnu_cxx17__normal_iteratorIPKcSsEESaINS_9sub_matchIS6_EEENS_12regex_traitsIcNS_16cpp_regex_traitsIcEEEEE18unwind_extra_blockEb[boost::re_detail::perl_matcher<__gnu_cxx::__normal_iterator<char const*, std::basic_string<char, std::char_traits<char>, std::allocator<char> > , std::allocator<boost::sub_match<__gnu_cxx::__normal_iterator<char const*, std::basic_string<char, std::char_traits<char>, std::allocator<char> > > > >, boost::regex_traits<char, boost::cpp_regex_traits<char> > ::unwind_extra_block(bool)]+0x48): undefined reference to `boost::re_detail::put_mem_block(void*)' collect2: ld returned 1 exit status
-- Hobbit Name: Pimpernel Loamsdown Registered Linux User: 275424 K7AZJ This email's Fortune: Yow! I want my nose in lights!
AMDG Jerry Davis wrote:
I am running ubuntu 9.04
I have built the libs from 1.39.0 with gcc 4.3 and moved them to /usr/local/boost
I have done a $ sudo ldconfig -v and have seen the boost libaries are installed
here is the code, taken from the boost web site:
#include <boost/regex.hpp> #include <iostream> #include <string>
using namespace std;
int main() { string line; boost::regex pat( "^Subject: (Re: |Aw: )*(.*)" );
while (cin) { getline(cin, line); boost::smatch matches; if (boost::regex_match(line, matches, pat)) cout << matches[2] << endl; } }
I can compile ok: g++ -I /usr/local/boost/include/boost-1_39 -c regex_example.cpp
But when I try to link I get a ton of errors, can anyone tell me what I need to do next? -- Jerry
$ g++ -I /usr/local/boost/include/boost-1_39 -L /usr/local/boost/lib regex_example.cpp
You need to link to the regex library with -lboost_regex. (or -lwhatever_the_boost_regex_library_is_named) In Christ, Steven Watanabe
On Fri, 14 Aug 2009 22:41:28 -0700 Steven Watanabe <watanabesj@gmail.com> wrote:
AMDG
Jerry Davis wrote:
I am running ubuntu 9.04
I have built the libs from 1.39.0 with gcc 4.3 and moved them to /usr/local/boost
I have done a $ sudo ldconfig -v and have seen the boost libaries are installed
here is the code, taken from the boost web site:
#include <boost/regex.hpp> #include <iostream> #include <string>
using namespace std;
int main() { string line; boost::regex pat( "^Subject: (Re: |Aw: )*(.*)" );
while (cin) { getline(cin, line); boost::smatch matches; if (boost::regex_match(line, matches, pat)) cout << matches[2] << endl; } }
I can compile ok: g++ -I /usr/local/boost/include/boost-1_39 -c regex_example.cpp
But when I try to link I get a ton of errors, can anyone tell me what I need to do next? -- Jerry
$ g++ -I /usr/local/boost/include/boost-1_39 -L /usr/local/boost/lib regex_example.cpp
You need to link to the regex library with -lboost_regex. (or -lwhatever_the_boost_regex_library_is_named)
In Christ, Steven Watanabe
_______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users
great. now i understand a lot better what the -l is for. -- Hobbit Name: Pimpernel Loamsdown Registered Linux User: 275424 K7AZJ This email's Fortune: Drinking is not a spectator sport. -- Jim Brosnan
participants (2)
-
Jerry Davis
-
Steven Watanabe