Error message:
./prog: error while loading shared libraries: xxx.so.0:
cannot open shared object file: No such file or directoryThis message means that the file xxx.so.0 could not be found. So the first thing to check is whether this .so file actually exists on your machine. If it does, we can conclude that the directory containing the xxx.so.0 dynamic library is simply not in the search path.
There are several ways to fix this problem.
1. Edit /etc/ld.so.conf
The /etc/ld.so.conf file is the configuration file for ld. Add a line at the end of this file containing the directory where xxx.so.0 resides.
In practice, my Fedora 19 file contains only this one line:
include ld.so.conf.d/*.confWhat this actually does is tell ld to search all the *.conf files under the ld.so.conf.d/ directory.
The benefit of this setup is that you can later remove groups of search paths one at a time.
If you already have this line, you can create a new .conf file under ld.so.conf.d/ and add the directory containing xxx.so.0 to it.
Then, run the command:
/sbin/ldconfig –vOnce the cache is updated, ld will search the target directory.
2. Modify the LD_LIBRARY_PATH environment variable to add a search directory
Edit files such as ~/.bashrc or ~/.bash_profile and add the following command:
# .so
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:YOUR_PATHThis adds your desired directory to the LD_LIBRARY_PATH environment variable.
Then run:
source .bash_profileto make the new settings take effect.
ld will also search all the paths under $LD_LIBRARY_PATH.
Alternatively, you can set LD_LIBRARY_PATH for a single command only, for example:
env LD_LIBRARY_PATH=YOUR_PATH:$LD_LIBRARY_PATH ./prog
Comments
No comments yet — be the first to write one.