Table of Contents
Ubuntu - Programs - Program can't find Shared Library at run-time
Error received when trying to run a program, such as error while loading shared libraries.
Symlinks on libraries work fine, as long as the final target they trace to exists and is accessible.
Possible solutions include:
- Create a symlink to the library path.
- Copy the library file to a directory listed in /etc/ld.so.conf.
- Add the directory containing the library files to /etc/ld.so.conf.
- Update the LD_LIBRARY_PATH environment variable.
- Recompile program statically.
After any of the first 3, rerun ldconfig so the linker cache is updated. You can then run ldconfig -v to verify it's resolvable.
Create a symlink to the library path
Create a symlink to the library path in a directory listed in /etc/ld.so.conf (or /lib or /usr/lib).
Assuming that the library file is named libxyz.so and that /usr/local/lib is one of the directories listed in /etc/ld.so.conf.
Then
ln -s libxyz.so /usr/local/lib/libxyz.so
Then update the linker cache.
ldconfig
The runtime linker (usually /lib/ld.so or /lib/ld-linux.so with some version number in it) checks all of its configured directories for the library, and then links them in every time the program starts.
Now run the program.
Copy the library file to a directory listed in /etc/ld.so.conf
Copy the library file to a directory listed in /etc/ld.so.conf (or /lib or /usr/lib) (defaults).
Assuming that the library file is named libxyz*
cat /etc/ld.so.conf
displays
include /etc/ld.so.conf.d/*.conf
Some Linux systems have the /etc/ld.so.conf file point directly to some directories, such as /usr/local/lib. Ubuntu however references a seperate directory /etc/ld.so.conf.d where is reads in any *.conf file. Simply create a new confile file with an extension ending in .conf. Populate this file with the path that contains the library file.
Then update the linker cache.
ldconfig
The runtime linker (usually /lib/ld.so or /lib/ld-linux.so with some version number in it) checks all of its configured directories for the library, and then links them in every time the program starts.
Now run the program.
Add the directory containing libxyz* to /etc/ld.so.conf
Add the directory containing libxyz* to /etc/ld.so.conf.
vi /etc/ld.so.conf
and add this line
- /etc/ld.so.conf
/directory/where/libxyz* exists
Then update the linker cache.
ldconfig
The runtime linker (usually /lib/ld.so or /lib/ld-linux.so with some version number in it) checks all of its configured directories for the library, and then links them in every time the program starts.
Now run the program.
Update your **LD_LIBRARY_PATH** environment variable
Add the directory containing the library files (or symbolic link) to your LD_LIBRARY_PATH environment variable.
set LD_LIBRARY_PATH=/directory/path/to/libxyz*
Now run the program.
Recompile program statically
It will work, but don't bother.