【发布时间】:2009-11-21 06:12:50
【问题描述】:
您好,我正在尝试在 boost 库中编译一个简单的程序,但我不断收到链接器错误
#include <iostream>
#include <string>
#include <boost\regex.hpp> // Boost.Regex lib
using namespace std;
int main( ) {
std::string s, sre;
boost::regex re;
while(true)
{
cout << "Expression: ";
cin >> sre;
if (sre == "quit")
{
break;
}
cout << "String: ";
cin >> s;
try
{
// Set up the regular expression for case-insensitivity
re.assign(sre, boost::regex_constants::icase);
}
catch (boost::regex_error& e)
{
cout << sre << " is not a valid regular expression: \""
<< e.what() << "\"" << endl;
continue;
}
if (boost::regex_match(s, re))
{
cout << re << " matches " << s << endl;
}
}
}
但我不断收到链接器错误
[Linker error] undefined reference to `boost::basic_regex<char, boost::regex_traits<char, boost::cpp_regex_traits<char> > >::do_assign(char const*, char const*, unsigned int)'
我该如何解决这个问题?
Ps:我正在使用 devcpp ide 并且我从 www.devpaks.org
【问题讨论】: