简体   繁体   中英

Linkage problem with Dev c++ and Boost::regex

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.

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM