Error loading shared libraries

I have a project organized as

\bin\cmain \lib\libxmlrpc_client++.a \lib\libxmlrpc_client++.so.4 \lib\libxmlrpc_client++.so.4.16 

My c program cmain needs to dynamically bind clib.so.4. While I am compiling the code, I use -L.../lib to specify the lib directory and use -lxmlrpc_client++ . However, my code gets an error while loading shared libraries:

 libxmlrpc_client++.so.4: cannot open shared object file: No such file or directory 

Any ideas to fix this?

PS: the problem is solved, a good link to the problem: http://gcc.gnu.org/ml/gcc-help/2005-12/msg00017.html

+7
source share
3 answers

You need to specify a dynamic linker where to look for libraries. Assuming this is some kind of UNIX / Linux system, this can be done either by setting the environment variable LD_LIBRARY_PATH before executing the program:

 export LD_LIBRARY_PATH=/path/to/lib ./run-my-program 

or by setting the linker path at compile time:

 gcc -L/path/to/lib -Wl,-rpath,/path/to/lib -lxmlrpc_client++ ... ./run-my-program 

Both approaches have problems. Google for "why LD_LIBRARY_PATH is bad." The command line options for setting the runtime linker path vary from one compiler to another.

+8
source

You should use -Llib instead of -L. .

0
source

Is this broken software link? ls -l, make sure you specify the correct file.

0
source

All Articles