0

I have developed a C++ class which reads in a text file and store some information in provate variables. To parse the file, I use regex library. During compilation there is an error I can't understand. First I make a shared object library for my class. Afterwards I try to compile the test program. Here the error occurs: undefined reference to std::regex_iterator...

I do the compilation with the following commands on a unix machine:

g++ -c -fpic -m64 -std=c++11 Foo.h Foo.cpp

g++ -shared -m64 -std=c++11 -o libFoo.so Foo.o

g++ -m64 -std=c++11 -I. -L. -lFoo -o camelTest Foo.h main.cpp

To reproduce the error, here is a small example: example

Thanks in advance for your help

user2672165
  • 2,910
  • 17
  • 26
Fabian
  • 57
  • 8

1 Answers1

0

g++ -m64 -std=c++11 -I. -L. -lFoo -o camelTest Foo.h main.cpp -L%PATH_TO_USED_LIB% -l%NAME_OF_LIB%

If your lib is libregexp, then %NAME_OF_LIB% == regexp

The idea is:

Flag -L(uppercase) tells gcc where your libs are.

Flag l(lowercase) tells gcc which library should gcc link to your application.

Edward
  • 304
  • 2
  • 15