What the ld.so Error Means
The ld.so (or ld-linux.so) error occurs when the Linux dynamic linker cannot find a shared library required to run a program. The full message typically looks like this:
error while loading shared libraries: libexample.so.1: cannot open shared object file: No such file or directory
This means the executable requires the libexample.so.1 library, but the loader cannot find it in the standard paths. The error appears immediately when attempting to run the command in the terminal and prevents the program from executing.
Common Causes
- Required library not installed — The program depends on a library that is missing from the system.
- Library installed in a non-standard path — The loader only searches for libraries in directories listed in
/etc/ld.so.confand theLD_LIBRARY_PATHvariable. - Incorrect permissions — The current user does not have permission to read the library file.
- Corrupted library — The library file is damaged or has an invalid format.
- Architecture mismatch — For example, a 32-bit library for a 64-bit program (or vice versa).
- Outdated library version — The program requires a specific version (e.g.,
libssl.so.1.1), but a different version is installed (e.g.,libssl.so.3).
Method 1: Installing the Missing Library
The most common scenario is that the library is simply not installed. First, determine which package provides the needed library.
For Ubuntu/Debian:
# Search for the package containing the library (e.g., libssl.so.1.1)
apt-file search libssl.so.1.1
# If apt-file is not installed, install it first:
sudo apt update && sudo apt install apt-file && sudo apt-file update
# Then install the found package:
sudo apt install libssl1.1
For CentOS/RHEL/Fedora:
# Search for the package
yum provides */libssl.so.1.1
# Or for Fedora with dnf:
dnf provides */libssl.so.1.1
# Install the package:
sudo yum install openssl-libs
# or
sudo dnf install openssl-libs
⚠️ Important: The library name in the error (e.g.,
libssl.so.1.1) may differ from the package name. Ensure you install the package with the correct version.
Method 2: Adding a Library Path to LD_LIBRARY_PATH
If the library already exists on the system but is located in a non-standard directory (e.g., /home/user/app/lib), you can temporarily add that path to the LD_LIBRARY_PATH environment variable.
# For the current terminal session:
export LD_LIBRARY_PATH=/home/user/app/lib:$LD_LIBRARY_PATH
# Then try running the program again.
To make the change permanent, add the line to ~/.bashrc or ~/.profile:
echo 'export LD_LIBRARY_PATH="/home/user/app/lib:$LD_LIBRARY_PATH"' >> ~/.bashrc
source ~/.bashrc
💡 Tip: Use this method only for user-specific installations. For system libraries, configuring
ldconfigis preferable (see Method 3).
Method 3: Updating the Library Cache (ldconfig)
If the library is installed in a standard system path (e.g., /usr/local/lib) but the loader does not see it, the cache may be outdated. Update it:
# Add the directory to ld.so configuration if it's not there:
echo '/usr/local/lib' | sudo tee -a /etc/ld.so.conf.d/custom.conf
# Update the cache:
sudo ldconfig
After this, the loader will be aware of the new libraries. Verify the library is visible:
ldconfig -p | grep libexample
Method 4: Checking Architecture and Dependencies
Ensure the library's architecture matches the program's.
# Check the library's architecture:
file /usr/lib/x86_64-linux-gnu/libexample.so.1
# Example output: libexample.so.1: ELF 64-bit LSB shared object, x86-64, ...
# Check the executable's architecture:
file /usr/bin/example-program
If the program is 64-bit and the library is 32-bit (or vice versa), install the library with the correct architecture. For example, in Ubuntu, 32-bit libraries are available in packages with the :i386 suffix.
Also, check all program dependencies using ldd:
ldd /usr/bin/example-program
This command shows which libraries are loaded and which are not found (marked as not found).
Method 5: Reinstalling the Application
If the library is bundled with the application (e.g., in an app/lib folder), the files might be corrupted or incomplete. Reinstall the application:
# For an application installed from a repository:
sudo apt reinstall example-package
# For an application downloaded manually:
# Remove the application folder and download it again.
If the application uses local libraries, ensure the launch script correctly sets LD_LIBRARY_PATH or uses rpath.
Prevention
- Install libraries from official repositories — This ensures compatibility and automatic updates.
- When compiling programs from source, use
--prefix=/usr/localand runsudo ldconfigaftermake install. - Avoid manually copying libraries to system paths without updating the cache.
- Keep your system updated —
sudo apt update && sudo apt upgrade(or equivalents for your distribution). - Use containers (Docker) to isolate dependencies if you need to avoid library conflicts.
If the issue affects multiple programs simultaneously, system libraries might be corrupted. In such cases, consider reinstalling core packages:
# Ubuntu/Debian:
sudo apt install --reinstall libc6 libstdc++6
# CentOS/RHEL:
sudo yum reinstall glibc libstdc++