简体   繁体   English

无法让 pcre 在 C++ 中工作

[英]can't get pcre to work in c++

I'm pretty new to c++, as in I'm still learning the basic of it我对 C++ 还很陌生,因为我仍在学习它的基础知识

anw.嗯。 I want to use pcre in it, but have so far been unsuccessful in getting it to work.我想在其中使用 pcre,但到目前为止还没有成功让它工作。

I'm running Ubuntu and have in my latest attempt tried to install the libpcre3-dev package (I should mention that I am rather new to Linux too)我正在运行 Ubuntu 并且在我最近的尝试中尝试安装 libpcre3-dev 包(我应该提到我对 Linux 也很陌生)

I included pcre with我包括 pcre

#include <pcrecpp.h>

currently I'm getting the error "undefined reference to pcrecpp::RE::no_arg" whenever I try to define an RE object当前,每当我尝试定义 RE 对象时,都会收到错误“对 pcrecpp::RE::no_arg 的未定义引用”

pcrecpp::RE reg("fys|smi|int|fok|arv|kar");

Can anyone explain to me what I'm doing wrong, and or give me a step by step guide on how to do it.任何人都可以向我解释我做错了什么,或者给我一个关于如何做的分步指南。

And I do know that c++ have a regex library, but since I'm used to pcre from php, that is what I'm going for而且我确实知道 c++ 有一个正则表达式库,但是由于我习惯从 php 进行 pcre,这就是我想要的

You should pass -lpcrecpp on the command line to link your program with the PCRE library.您应该在命令行上传递-lpcrecpp以将您的程序与 PCRE 库链接。 Just including the declarations in a header file is not enough.仅在头文件中包含声明是不够的。

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

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