c++ - 帮助在 C++ 中使用 PCRE

标签 c++ windows g++ pcre codeblocks

这是我第一次尝试构建 C++ 应用程序,所以我有点迷失。我看过一些例子,但我仍然不知道出了什么问题。

#include <iostream>
#include <stdio.h>
#include <windows.h>
#include <pcrecpp.h>
#include <string>
#include <cstring>

using namespace std;

int main()
{
    char title[256];
    char url[256];
    string song, diff;
    HWND hwnd = FindWindow("WindowsForms10.Window.8.app.0.33c0d9d", NULL);
    GetWindowTextA(hwnd, title, 255);
    pcrecpp::RE re("^osu!  - (.*) \\[(.*)\\] \\[[|-]{21}\\]$");
    re.FullMatch(title, &song, &diff);
    sprintf(url, "xfire:game_stats?game=%s&%s=%s&%s=%s", "osu", "Playing", song.c_str(), "Difficulty", diff.c_str());
    ShellExecute(NULL, NULL, url, NULL, NULL, SW_SHOWDEFAULT);
    return 0;
}

当我尝试编译时,出现以下编译器错误

obj\Debug\main.o||在函数“main”中:| C:\Users\Zeffy\Desktop\osu-gamestats\main.cpp|18|对“_imp___ZN7pcrecpp2RE6no_argE”的 undefined reference | C:\Users\Zeffy\Desktop\osu-gamestats\main.cpp|18|对“_imp___ZN7pcrecpp2RE6no_argE”的 undefined reference | C:\Users\Zeffy\Desktop\osu-gamestats\main.cpp|18|对“_imp___ZN7pcrecpp2RE6no_argE”的 undefined reference | C:\Users\Zeffy\Desktop\osu-gamestats\main.cpp|18|对“_imp___ZN7pcrecpp2RE6no_argE”的 undefined reference | C:\Users\Zeffy\Desktop\osu-gamestats\main.cpp|18|对“_imp___ZN7pcrecpp2RE6no_argE”的 undefined reference | obj\Debug\main.o:C:\Users\Zeffy\Desktop\osu-gamestats\main.cpp|18|更多对“_imp___ZN7pcrecpp2RE6no_argE”的 undefined reference 如下| obj\Debug\main.o||在函数“main”中:| C:\Users\Zeffy\Desktop\osu-gamestats\main.cpp|18|对'_imp___ZNK7pcrecpp2RE9FullMatchERKNS_11StringPieceERKNS_3ArgES6_S6_S6_S6_S6_S6_S6_S6_S6_S6_S6_S6_S6_S6_S6_'的 undefined reference | C:\Users\Zeffy\Desktop\osu-gamestats\main.cpp|17|对“_imp___ZN7pcrecpp2RED1Ev”的 undefined reference | C:\Users\Zeffy\Desktop\osu-gamestats\main.cpp|17|对“_imp___ZN7pcrecpp2RED1Ev”的 undefined reference | obj\Debug\main.o||在函数“Arg”中:| C:\MinGW\msys\1.0\local\include\pcrecpparg.h|89|对“_imp___ZN7pcrecpp3Arg12parse_stringEPKciPv”的 undefined reference | obj\Debug\main.o||在函数“RE”中:| C:\MinGW\msys\1.0\local\include\pcrecpp.h|493|对“_imp___ZN7pcrecpp2RE4InitERKSsPKNS_10RE_OptionsE”的 undefined reference | ||=== 构建完成:11 个错误,0 个警告 ===|

最佳答案

_imp___ZN7pcrecpp2RE6no_argE 是一个损坏的名称。由于它包含 pcrecppno_arg 部分,我怀疑问题在于您无法链接到 Pcrecpp。因此,no_arg 符号未定义。

关于c++ - 帮助在 C++ 中使用 PCRE,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4655403/

相关文章:

c++ - Netbeans c/c++ 远程执行

Java向文本文件的特定部分添加行

c++ - 编译时出现警告,但程序可以运行;该怎么办?

visual-c++ -/show在g++中包含等效选项

c++ - 在这种情况下我的时间复杂性偏执症是否合理?

c++ - STD 文件流损坏? (内部文件缓冲区为空,无法读取输入)

windows - 获取应用程序池的标识

windows - 在 Windows OpenGL 中显示诊断文本的最佳方式

c++ - GNU Make 产生完全不同的结果

c++ - 相关 C++ 类中多态性的最佳实践?