0
votes

I'm having a problem using the Boost library in Dev C++, specifically the regex one. I've tried using their example code:

#include string
#include iostream

using namespace boost; 

regex expression("([0-9]+)(\\-| |$)(.*)"); 

// process_ftp: 
// on success returns the ftp response code, and fills 
// msg with the ftp response message. 
int process_ftp(const char* response, std::string* msg) 
{ 
   cmatch what; 
   if(regex_match(response, what, expression)) 
   { 
      // what[0] contains the whole string 
      // what[1] contains the response code 
      // what[2] contains the separator character 
      // what[3] contains the text message. 
      if(msg) 
         msg->assign(what[3].first, what[3].second); 
      return std::atoi(what[1].first); 
   } 
   // failure did not match 
   if(msg) 
      msg->erase(); 
   return -1; 
}

The error it's throwing me is:

[Linker error] undefined reference to `boost::re_detail::get_mem_block()'

Along with many others linker errors. I can't seem to find the way to fix it, even when searching for this problem I've come across other compilers. I've already added the include paths to the project for the other header files.

How I'm supposed to get around it? And if I have to change something on the way DevC++ compiles is from the Files tab or the Parameters one? And also, on not a way-too-diferent side note, can someone recommend me a good guide or page about Compilers and/or something that could help me? (since I couldn't find much in the c++ page).

Thanks.

1
(this has nothing to do with your problem, but...) Dev-C++ uses a stone age compiler (GCC 3.4.5 if I'm not mistaken), together with a stone-age MinGW version. The IDE itself is by now also stone-age, so see to upgrading those when you get the chance, you won't regret it ;).rubenvb
I did download the last version of MinGW right now. ThanksFilgera

1 Answers

0
votes

As far as I know you should build the boost regex library and link to it. I assume you are not linking against the regex library.

You can find instructions on building the library here: http://www.boost.org/doc/libs/1_45_0/libs/regex/doc/html/boost_regex/install.html