读书人

用boost:regex时链接出错

发布时间: 2012-03-24 14:00:46 作者: rapoo

求助:用boost:regex时链接出错
程序是书上的例子:
#include <iostream>
#include <cassert>
#include <string>
#include "boost/regex.hpp "

int main() {
boost::regex reg( "\\d{3}([a-zA-Z]+).(\\d{2}|N/A)\\s\\1 ");

std::string correct= "123Hello N/A Hello ";
std::string incorrect= "123Hello 12 hello ";

assert(boost::regex_match(correct,reg)==true);
assert(boost::regex_match(incorrect,reg)==false);
system( "pause ") ;
return 0 ;
}

编译时出现链接错误:
F:\test1\Debug\test(.text$_ZN5boost11basic_regexIcNS_12regex_traitsIcEESaIcEED1Ev+0xd): In function `ZN5boost9re_detail11saved_stateC2Ej ':
D:\Program files\boost\boost\regex\v4\perl_matcher.hpp: undefined reference to `boost::reg_expression <char, boost::regex_traits <char> , std::allocator <char> > ::~reg_expression() '
太多,这个只是一部分。

编译用到像shared_ptr不需要链接的都可以通过,但是如果需要链接的就不行
是什么原因?
我的lib文件夹下都是bjam运行后全部的.lib和.dll文件,debug和release的都有,版本号也有,编译器用dev和mingw都试过,都试这个问题。




[解决办法]
lib问题

在dev-c++中使用boost应该指定编译器为:mingw,而不是GCC
这是有区别的

读书人网 >C++

热点推荐