【问题标题】:Help using PCRE in C++帮助在 C++ 中使用 PCRE
【发布时间】:2011-06-07 00:36:03
【问题描述】:

这是我第一次尝试构建 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||In function 'main':| C:\Users\Zeffy\Desktop\osu-gamestats\main.cpp|18|undefined reference to '_imp___ZN7pcrecpp2RE6no_argE'| C:\Users\Zeffy\Desktop\osu-gamestats\main.cpp|18|undefined reference to '_imp___ZN7pcrecpp2RE6no_argE'| C:\Users\Zeffy\Desktop\osu-gamestats\main.cpp|18|undefined reference to '_imp___ZN7pcrecpp2RE6no_argE'| C:\Users\Zeffy\Desktop\osu-gamestats\main.cpp|18|undefined reference to '_imp___ZN7pcrecpp2RE6no_argE'| C:\Users\Zeffy\Desktop\osu-gamestats\main.cpp|18|undefined reference to '_imp___ZN7pcrecpp2RE6no_argE'| obj\Debug\main.o:C:\Users\Zeffy\Desktop\osu-gamestats\main.cpp|18|more undefined references to '_imp___ZN7pcrecpp2RE6no_argE' follow| obj\Debug\main.o||In function 'main':| C:\Users\Zeffy\Desktop\osu-gamestats\main.cpp|18|undefined reference to '_imp___ZNK7pcrecpp2RE9FullMatchERKNS_11StringPieceERKNS_3ArgES6_S6_S6_S6_S6_S6_S6_S6_S6_S6_S6_S6_S6_S6_S6_'| C:\Users\Zeffy\Desktop\osu-gamestats\main.cpp|17|undefined reference to '_imp___ZN7pcrecpp2RED1Ev'| C:\Users\Zeffy\Desktop\osu-gamestats\main.cpp|17|undefined reference to '_imp___ZN7pcrecpp2RED1Ev'| obj\Debug\main.o||In function 'Arg':| C:\MinGW\msys\1.0\local\include\pcrecpparg.h|89|undefined reference to '_imp___ZN7pcrecpp3Arg12parse_stringEPKciPv'| obj\Debug\main.o||In function 'RE':| C:\MinGW\msys\1.0\local\include\pcrecpp.h|493|undefined reference to '_imp___ZN7pcrecpp2RE4InitERKSsPKNS_10RE_OptionsE'| ||=== Build finished: 11 errors, 0 warnings ===|

【问题讨论】:

    标签: c++ windows g++ pcre codeblocks


    【解决方案1】:

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

    【讨论】:

      猜你喜欢
      • 2010-12-30
      • 1970-01-01
      • 2011-07-21
      • 1970-01-01
      • 1970-01-01
      • 2018-07-17
      • 2014-09-13
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多