Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/.htaccess/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C++ 编译错误C++;-使用PCRE库的未定义引用_C++_Regex_Pcre_Linker Errors - Fatal编程技术网

C++ 编译错误C++;-使用PCRE库的未定义引用

C++ 编译错误C++;-使用PCRE库的未定义引用,c++,regex,pcre,linker-errors,C++,Regex,Pcre,Linker Errors,我在编译代码以测试PCRE库是否正确安装时遇到问题 #include <string> #include <iostream> #include <pcre.h> int main (int argc, char *argv[]) { const char *error; int erroffset; pcre *re; int rc; int i; int ovect

我在编译代码以测试PCRE库是否正确安装时遇到问题

#include <string> 
#include <iostream> 
#include <pcre.h> 



int main (int argc, char *argv[]) 

{ 
    const char *error; 
    int   erroffset; 
    pcre *re; 
    int   rc; 
    int   i; 
    int   ovector[100]; 

    char *regex = "From:([^@]+)@([^\r]+)"; 
    char str[]  = "From:regular.expressions@example.com\r\n"\ 
                  "From:exddd@43434.com\r\n"\ 
                  "From:7853456@exgem.com\r\n"; 

    re = pcre_compile (regex,          /* the pattern */ 
                       PCRE_MULTILINE, 
                       &error,         /* for error message */ 
                       &erroffset,     /* for error offset */ 
                       0);             /* use default character tables */ 
    if (!re) 
    { 
        printf("pcre_compile failed (offset: %d), %s\n", erroffset, error); 
        return -1; 
    } 

    unsigned int offset = 0; 
    unsigned int len    = strlen(str); 
    while (offset < len && (rc = pcre_exec(re, 0, str, len, offset, 0, ovector, sizeof(ovector))) >= 0) 
    { 
        for(int i = 0; i < rc; ++i) 
        { 
            printf("%2d: %.*s\n", i, ovector[2*i+1] - ovector[2*i], str + ovector[2*i]); 
        } 
        offset = ovector[1]; 
    } 
    return 1; 
} 
我很确定我在做些蠢事

当前使用IDE Dev-C++,使用开发包管理器安装了该包

这是DevPak软件包安装程序:我用来安装库(pcre-6.4.1)

我需要一些指导,引导我正确安装这个库(这样我就可以使用正则表达式)

如果不是,我希望引用C++库来支持在这个DEV-C++或CODBROCK上安装的正则表达式。 谢谢你的帮助

编辑: 感谢您的帮助,通过检查此线程解决了此问题


两个线程中都有愚蠢的程序员的响应。

您是否存在名称混乱问题?pcre.h里面有类似的东西吗

extern "C" {
   // declarations of c functions for c++
 }

如果不包你的包含,它会通知C++它调用C函数< /p> 你有名字的问题吗?pcre.h里面有类似的东西吗

extern "C" {
   // declarations of c functions for c++
 }

<如果不将你的包括起来,它会告诉C++它调用C函数< /p>命令行做什么链接?你尝试设置路径和库依赖关系吗?你是否链接到正确的标志(例如,像代码> G+ +什么?LPRCE < /代码>)?除了我所提到的,我没有做任何其他事情。如何设置路径和库依赖项,以及需要设置什么?命令行是如何进行链接的?是否尝试设置路径和库依赖项?是否使用正确的标志进行链接(例如,类似
g++whatever-lprce
)?除了我提到的以外,我没有做任何其他事情。如何设置路径和库依赖项,以及需要将它们设置为什么?