3

I'm pretty new to c++, as in I'm still learning the basic of it

anw. I want to use pcre in it, but have so far been unsuccessful in getting it to work.

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)

I included pcre with

#include <pcrecpp.h>

currently I'm getting the error "undefined reference to pcrecpp::RE::no_arg" whenever I try to define an RE object

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

Zlug
  • 373
  • 2
  • 15
  • You're getting this error when you link? Are you linking with the PCRE library? – David Schwartz Nov 26 '12 at 14:00
  • Is your library path(-L tag) set properly to point to the location where your .so files are located for the libpcre package?? – DumbCoder Nov 26 '12 at 14:00
  • I get the error when I compile, and I have no idea about the other things, which is why I ask – Zlug Nov 26 '12 at 14:05
  • There are various possible duplicates of this question: http://stackoverflow.com/questions/12294404/pcre-error-undefined-symbol-zn7pcrecpp2re6no-arge, http://stackoverflow.com/questions/5568644/compiling-error-c-undefined-references-using-pcre-library, http://stackoverflow.com/questions/6509834/how-can-i-link-my-c-code-with-the-pcre-library-linker-errors-currently-being-t, http://stackoverflow.com/questions/4655403/help-using-pcre-in-c – jogojapan Nov 26 '12 at 14:06

1 Answers1

3

You should pass -lpcrecpp on the command line to link your program with the PCRE library. Just including the declarations in a header file is not enough.

Alexey Feldgendler
  • 1,792
  • 9
  • 17