Joe
Joe

Reputation: 3089

c/c++ boost - problem compiling

I've been pulling my hair out trying to figure out how to compile my app with boost regex.

I've installed boost from source on centos 5.

g++ -lboost_regex -o my_app my_app.c $(mysql_config --libs --cflags)

It compiles without any errors, however when I execute it:

error while loading shared libraries: libboost_regex.so.1.46.1: cannot open shared object file: No such file or directory

The location of that file is:

/usr/local/lib/libboost_regex.so.1.46.1

Anyone experience the same issues?

Upvotes: 0

Views: 1625

Answers (2)

Mark B
Mark B

Reputation: 96233

Did you try LD_LIBRARY_PATH=/usr/local/lib:$LD_LIBRARY_PATH your_program to make sure it knows where to find the shared object? You can set the path when you link by using -Wl,-R/usr/local/lib.

EDIT: To be more clear, when you link your code the linker will embed an RPATH and RUNPATH into the binary. These values tell the runtime loader where to find required shared objects.

If you add -Wl,-R/usr/local/lib to your link command that should cause it to embed that directory and always check it when loading your program.

Upvotes: 3

0x1F602
0x1F602

Reputation: 865

Try this.

$ LD_LIBRARY_PATH=/usr/local/lib:LD_LIBRARY_PATH
$ export LD_LIBRARY PATH

Now try and tell us what happens.

Upvotes: 0

Related Questions