Boost will not compile

I am using boost 1.45.0 on Ubuntu with Code :: Blocks as my IDE, and I cannot get basic_regex.hpp to compile. I am sure I configured boost correctly, because I can compile programs using boost :: format without any errors. But I get this annoying mistake, and I don’t know how to get rid of it.

Error code:

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 ===| 

Am I missing the step when setting up boost or do I need to upgrade to another version of boost?

+4
source share
3 answers

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

+11
source

Boost :: Regex has code that lives in a separate library (libboost_regex.so). To link this, add -lboost_regex to the GCC command line you use.

Depending on your installation, this might be libboost_regex-mt.so. In this case, you need to use -lboost_regex-mt on the command line. (MT stands for mutlithreaded.)

+8
source

This is a communication error, not a compiler error. You need to explicitly link to the Boost regex library.

 g++ program.cpp -lboost_regex -L/path/to/boost/lib 
+2
source

Source: https://habr.com/ru/post/1333254/


All Articles