【问题标题】:How do I get PCRE to work correctly with Code::blocks?如何让 PCRE 与 Code::blocks 一起正常工作?
【发布时间】:2013-07-12 00:06:44
【问题描述】:

我在 Code::blocks 中使用 PCRE 时遇到了一些问题。我已经从here 下载了 PCRE。并完成了here 提到的所有步骤。但是我在执行过程中遇到 pcr3.dll 丢失错误。

程序无法启动,因为您的电脑中缺少 pcre3.dll 电脑。尝试重新安装程序以解决此问题。

My code:

#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(&reg,pattern.c_str(),REG_EXTENDED|REG_ICASE);

 if (regexec(&reg,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(&reg);

  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


【解决方案1】:

将 DLL 复制到与您正在运行的可执行文件相同的目录中。如果这样可行,则说明您没有正确安装 DLL,或者至少没有以通常程序可以找到的方式安装 DLL。查看DLL Search Order 的文档,了解如何让系统找到 DLL。特别是,您需要知道有一个链接器和一个加载器(也称为动态/运行时链接器/加载器),但在 CodeBlocks 中只配置了其中一个!

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2019-04-27
    • 1970-01-01
    • 1970-01-01
    • 2018-08-23
    • 2017-02-27
    • 2021-12-27
    • 2012-07-02
    • 1970-01-01
    相关资源
    最近更新 更多