George Young
George Young

Reputation: 355

c++ pcre2_compile gets incomplete type

[g++4.8.2, pcre2-10.31, linux] [c++ ~newbie] I'm trying to learn how to use some simple calls to pcre2 from a c++ program.

#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

Thanks, I fixed the pointer problem, still get 'undefined reference'...?

Upvotes: 0

Views: 1176

Answers (1)

George Young
George Young

Reputation: 355

Got it, thanks all: 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

Upvotes: 1

Related Questions