Sos Aleksanyan
Sos Aleksanyan

Reputation: 11

Boost::regex_match fails

I need to use regular expression matching in my program. I decided to use boost library for it, but I receive strange fail when trying to compile. What is wrong?? There is my code:

...
#include <boost/regex.hpp>
...
using namespace boost;
...
map <string, double>::iterator container::find (string toFind)
{
    iterator it;
    for (it=mainMap.begin(); it!=mainMap.end(); it++)
    {
        regex e ((*it).first);            //this line works correct
        if ( regex_match (toFind, e ) )
            return it;
    }
    return it;
}
...

Error message is to big for posting, there is its beginning:

tmp/cczkfDcy.o(.gnu.linkonce.t._ZN5boost11basic_regexIcNS_12regex_traitsIcEESaIcEED1Ev+0x11): In function boost::basic_regex<char, boost::regex_traits<char>, std::allocator<char> >::~basic_regex()': : undefined reference to boost::reg_expression, std::allocator >::~reg_expression()' ...

Upvotes: 0

Views: 248

Answers (1)

Rafał Rawicki
Rafał Rawicki

Reputation: 22690

Add:

-lboost_regex

to your compiler options.

Upvotes: 1

Related Questions