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
need to dynamically link clib.so.4. While I compile the code, I use -L.../lib
to indicate directory lib
and use -lxmlrpc_client++
. However, my code get 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: Problem solved, a good reference to the problem: http://gcc.gnu.org/ml/gcc-help/2005-12/msg00017.html
Once you've created a shared library, you'll want to install it. The simple approach is simply to copy the library into one of the standard directories (e.g., /usr/lib) and run ldconfig(8). Finally, when you compile your programs, you'll need to tell the linker about any static and shared libraries that you're using.
cannot open shared object file: No such file or directory The reason behind this error is that the libraries of the program have been installed in a place where dynamic linker cannot find it.
Sometimes, the shared library might not exist or might be located in a non-standard path. As a result, we get the “cannot open shared object file: No such file or directory” at program launch.
You need to run the ldconfig command to effect the changes. After creating your shared library, you need to install it. You can either move it into any of the standard directories mentioned above and run the ldconfig command.
You need to tell the dynamic linker where to look for the libraries. Assuming this is some sort of UNIX/Linux system, this can be done either via setting the LD_LIBRARY_PATH environment variable before executing the program:
export LD_LIBRARY_PATH=/path/to/lib
./run-my-program
or by setting the run-time linker path during 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 run-time linker path varies from one compiler to another.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With