简体   繁体   English

帮助在C ++中使用PCRE

[英]Help using PCRE in C++

this is my first time trying to build a C++ application, so I'm kind of lost. 这是我第一次尝试构建C ++应用程序,所以我有点迷失了。 I've looked at some examples but I still dont really know what's wrong. 我看了一些例子,但我仍然真的不知道出什么问题了。

#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;
}

When I try to compile, I get the following compiler errors 当我尝试编译时,出现以下编译器错误

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 ===|

_imp___ZN7pcrecpp2RE6no_argE is a mangled name. _imp___ZN7pcrecpp2RE6no_argE是错误的名称。 Since it contains the parts pcrecpp and no_arg , I suspect that the problem is that you fail to link against Pcrecpp. 由于它包含部件pcrecppno_arg ,我怀疑问题是您无法针对Pcrecpp进行链接。 Therefore, the no_arg symbol is not defined. 因此, no_arg符号。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM