Launching compiled binary executables, proprietary development tools, or third-party software on Ubuntu only to be stopped by the error “error while loading shared libraries: libsomething.so.X: cannot open shared object file: No such file or directory” indicates a dynamic linker failure. In Linux, dynamically linked programs do not embed every functional library directly inside the binary file; instead, they rely on the dynamic linker (ld.so) to load required shared object (.so) libraries into memory at runtime. This error occurs when the required library is not installed, installed under an alternate architecture (32-bit vs 64-bit), or stored in a directory missing from the dynamic linker cache.
Identify Missing Shared Libraries with ldd
The ldd utility prints all shared object dependencies required by a program alongside their resolved filesystem paths.
- Open a terminal window (press Ctrl + Alt + T).
- Run
lddagainst the problematic binary executable:ldd /path/to/your/program - Review the output list. Any dependency that fails to link will be flagged with:
libexample.so.1 => not found - Note the exact name of the missing library file.
Find and Install the Package Providing the Library with apt-file
The standard Ubuntu APT repository contains tens of thousands of packages. Determining which specific package provides a particular .so file requires the apt-file indexing tool.
- Install
apt-fileif it is not already present:sudo apt update && sudo apt install apt-file -y - Update the package contents index cache:
sudo apt-file update - Search for the missing shared object file:
apt-file search libexample.so.1 - Review the search results to find the corresponding package name (e.g.
libexample1). - Install the package using apt:
sudo apt install libexample1 - Run your program again to confirm successful execution.
Update the Dynamic Linker Cache with ldconfig
If you compiled or manually installed a library into /usr/local/lib or a custom directory, the dynamic linker will not recognize the new files until the cache is refreshed.
- Check if the library file exists in standard directories:
sudo find / -name "libexample.so*" 2>/dev/null - If the file is located in
/usr/local/lib, verify that this directory is included in the dynamic linker configuration:cat /etc/ld.so.conf.d/*.conf - If absent, create a custom configuration entry:
echo "/usr/local/lib" | sudo tee /etc/ld.so.conf.d/custom-libs.conf - Rebuild the dynamic linker cache bindings:
sudo ldconfig
Export LD_LIBRARY_PATH for Standalone Applications
For standalone applications, proprietary games, or Anaconda environments where libraries reside inside a dedicated project subfolder, configuring the LD_LIBRARY_PATH variable directs the dynamic linker to custom directories.
- Temporarily append the application library path before running the binary:
export LD_LIBRARY_PATH=/opt/myapp/lib:$LD_LIBRARY_PATH ./myapp - To make this change permanent for your user account, add the export line to your
~/.bashrcfile:echo 'export LD_LIBRARY_PATH=/opt/myapp/lib:$LD_LIBRARY_PATH' >> ~/.bashrc source ~/.bashrc
Enable Multiarch Support for 32-Bit Libraries
If you are attempting to run older 32-bit binaries (such as legacy Wine applications or retro game engines) on a 64-bit Ubuntu installation, 64-bit libraries cannot fulfill 32-bit linking requirements.
- Enable the 32-bit (i386) architecture on your system:
sudo dpkg --add-architecture i386 sudo apt update - Install the 32-bit variant of the missing library (appending
:i386to the package name):sudo apt install libexample1:i386 - Run the binary again. The 32-bit dynamic linker will load the i386 shared object cleanly.