Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

boost's regex won't compile

Tags:

c++

regex

gcc

boost

I am using boost 1.45.0 on Ubuntu with Code::Blocks as my IDE, and I can't get basic_regex.hpp to compile. I'm pretty sure I set up boost correctly, because I can compile programs using boost::format without any errors. But I'm getting this annoying error, and I don't know how to get rid of it.

The code that is provoking the error:

boost::regex e("\"http:\\\\/\\\\/localhostr.com\\\\/files\\\\/.+?\"");

Compiler output (GCC):

obj/Debug/main.o
In function `boost::basic_regex<char, boost::regex_traits<char, boost::cpp_regex_traits<char> > >::assign(char const*, char const*, unsigned int)'

/home/neal/Documents/boost_1_45_0/boost/regex/v4/basic_regex.hpp|379|
undefined reference to `boost::basic_regex<char, boost::regex_traits<char, boost::cpp_regex_traits<char> > >::do_assign(char const*, char const*, unsigned int)'|

||=== Build finished: 1 errors, 0 warnings ===|

Did I miss a step when setting up boost, or should I downgrade to another version of boost?

like image 623
Neal P Avatar asked Dec 24 '10 01:12

Neal P


1 Answers

This looks like a linker error. boost::regex is not a header only library so you need to pass -lboost_regex with correct -L/path/to/boost/lib to linker.

like image 132
Vikas Avatar answered Oct 11 '22 14:10

Vikas