[g ++ 4.8.2,pcre2-10.31,linux] [c ++ ~newsbie] 我正在尝试学习如何从c ++程序中使用对pcre2的一些简单调用。
#include <string>
#define PCRE2_CODE_UNIT_WIDTH 8
#include "pcre2.h"
int main()
{
std::string xpattern = "(\\+|-)?[[:digit:]]+";
int errorcode;
PCRE2_SIZE *erroroffset = NULL;
pcre2_code *code = pcre2_compile((const unsigned char *)xpattern.c_str(), PCRE2_ZERO_TERMINATED, 0, &errorcode, erroroffset, NULL);
}
g++ -I/scratch_b/qa/tmp/pcre/include -g -Wall -o simple simpleregex2.cpp
simpleregex2.cpp: In function ‘int main()’:
simpleregex2.cpp:9:15: warning: unused variable ‘code’ [-Wunused-variable]
pcre2_code *code = pcre2_compile((const unsigned char *)xpattern.c_str(), PCRE2_ZERO_TERMINATED, 0, &errorcode, erroroffset, NULL);
^
simpleregex2.cpp:9: error: undefined reference to 'pcre2_compile_8'
collect2: error: ld returned 1 exit status
谢谢,我修复了指针问题,仍然得到'未定义的引用'......?
答案 0 :(得分:0)
知道了,谢谢大家: g ++ -I / scratch_b / qa / tmp / pcre // include -g -Wall simpleregex2.cpp -o simple -Wl,-rpath,/ scratch_b / qa / tmp / pcre // lib -L / scratch_b / qa / tmp / pcre // lib -lpcre2-8