Boost logo

Boost Users :

Subject: Re: [Boost-users] regex
From: John Maddock (john_at_[hidden])
Date: 2010-01-03 04:39:13


> I have #included <boost/regex.hpp> in a file but get the following compile
> time
> error:
>
>
> /tmp/ccXM0HkR.o: In function `boost::basic_regex<char,
> boost::regex_traits<char,
> boost::cpp_regex_traits<char> > >::assign(char const*, char const*,
> unsigned int)':
> contact.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)]+0x27): undefined reference to
> `boost::basic_regex<char, boost::regex_traits<char,
> boost::cpp_regex_traits<char>
>> >::do_assign(char const*, char const*, unsigned int)'
> collect2: ld returned 1 exit status
>
>
> This file definitely exists at /usr/include/boost/regex.hpp.
> Another Boost #include in the same file
> (<boost/date_time/posix_time/posix_time.hpp>) produces no error.
> 'ldconfig -p' lists libboost_regex.so.
>
> What am I doing wrong?

First off it's not a compile time error - it's a linker error - the linker
is saying that some symbols used by your program can't be found. In short
you need to add a reference to libboost_regex on the command line, something
like:

g++ myfile.cpp -lboost_regex

HTH, John.


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net