【发布时间】:2013-07-12 00:06:44
【问题描述】:
我在 Code::blocks 中使用 PCRE 时遇到了一些问题。我已经从here 下载了 PCRE。并完成了here 提到的所有步骤。但是我在执行过程中遇到 pcr3.dll 丢失错误。
程序无法启动,因为您的电脑中缺少 pcre3.dll 电脑。尝试重新安装程序以解决此问题。
#include <iostream>
#include <regex.h>
using namespace std;
int main(){
regex_t reg;
string pattern = "[^tpr]{2,}";
string str = "topcoder";
regmatch_t matches[1];
regcomp(®,pattern.c_str(),REG_EXTENDED|REG_ICASE);
if (regexec(®,str.c_str(),1,matches,0)==0) {
cout << "Match " ;
cout << str.substr(matches[0].rm_so,matches[0].rm_eo-matches[0].rm_so) ;
cout << " found starting at: " ;
cout << matches[0].rm_so ;
cout << " and ending at " ;
cout << matches[0].rm_eo ;
cout << endl;
} else {
cout << "Match not found.";
cout << endl;
}
regfree(®);
return 0;
}
我不知道如何解决这个问题,有什么想法吗?
PS:以上代码取自this教程。
【问题讨论】:
-
只是仔细检查,但您是否阅读了链接到的帖子中的this comment?您收到的错误消息让我想知道(a)
pcr3.dll在您的文件系统中的位置以及(b)您是否在 Code::Blocks 的设置中添加了必要的包含和库路径。 (也就是说,您是否提供了 Code::Blocks 以及包含pcr3.dll的目录的路径?) -
是的,我做到了。我已经在搜索目录中链接了包含
pcr3.dll的文件夹。 -
嗯...您是否也将
pcre3.dll添加到要链接的库列表中? (我不使用 Code::Blocks,但它会是 step 5B in this tutorial。)听起来您可能将包含pcre3.dll的目录添加到链接器搜索路径(这很好),但未能指定库本身.您也可以尝试在 forums.codeblocks.org 上提问。
标签: c++ regex windows codeblocks