与Dev c ++和Boost :: regex的链接问题

时间:2011-01-05 08:39:16

标签: c++ boost

我在使用Dev C ++中的Boost库时遇到问题,特别是正则表达式。我尝试过使用他们的示例代码:

#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; 
}

它给我的错误是:

  

[链接器错误]未定义引用`boost :: re_detail :: get_mem_block()'

与许多其他链接器错误一起。我似乎无法找到修复方法,即使在搜索此问题时我也遇到过其他编译器。我已经为其他头文件添加了项目的包含路径。

我该如何绕过它?如果我必须改变DevC ++编译的方式来自Files选项卡或Parameters one? 而且,不是一个太不同的旁注,有人可以推荐我一个关于编译器的好指南或页面和/或可以帮助我的东西吗? (因为我在c ++页面中找不到多少内容。)

感谢。

1 个答案:

答案 0 :(得分:0)

据我所知,你应该构建boost regex库并链接到它。我假设您没有链接到正则表达式库。

您可以在此处找到有关构建库的说明:http://www.boost.org/doc/libs/1_45_0/libs/regex/doc/html/boost_regex/install.html

相关问题