Your library is a dynamic library. You need to tell the operating system where it can locate it at runtime.

To do so, we will need to do those easy steps:

  1. Find where the library is placed if you don't know it.

    sudo find / -name the_name_of_the_file.so
    
  2. Check for the existence of the dynamic library path environment variable(LD_LIBRARY_PATH)

    echo $LD_LIBRARY_PATH
    

    If there is nothing to be displayed, add a default path value (or not if you wish to)

    LD_LIBRARY_PATH=/usr/local/lib
    
  3. We add the desired path, export it and try the application.

    Note that the path should be the directory where the path.so.something is. So if path.so.something is in /my_library/path.so.something, it should be:

    export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/my_library/
    

Reference to source

Answer from XOR on Stack Overflow
Top answer
1 of 16
622

Your library is a dynamic library. You need to tell the operating system where it can locate it at runtime.

To do so, we will need to do those easy steps:

  1. Find where the library is placed if you don't know it.

    sudo find / -name the_name_of_the_file.so
    
  2. Check for the existence of the dynamic library path environment variable(LD_LIBRARY_PATH)

    echo $LD_LIBRARY_PATH
    

    If there is nothing to be displayed, add a default path value (or not if you wish to)

    LD_LIBRARY_PATH=/usr/local/lib
    
  3. We add the desired path, export it and try the application.

    Note that the path should be the directory where the path.so.something is. So if path.so.something is in /my_library/path.so.something, it should be:

    export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/my_library/
    

Reference to source

2 of 16
269

Here are a few solutions you can try:

ldconfig

As AbiusX pointed out: If you have just now installed the library, you may simply need to run ldconfig.

sudo ldconfig

ldconfig creates the necessary links and cache to the most recent shared libraries found in the directories specified on the command line, in the file /etc/ld.so.conf, and in the trusted directories (/lib and /usr/lib).

Usually your package manager will take care of this when you install a new library, but not always, and it won't hurt to run ldconfig even if that is not your issue.

Dev package or wrong version

If that doesn't work, I would also check out Paul's suggestion and look for a "-dev" version of the library. Many libraries are split into dev and non-dev packages. You can use this command to look for it:

apt-cache search <libraryname>

This can also help if you simply have the wrong version of the library installed. Some libraries are published in different versions simultaneously, for example, Python.

Library location

If you are sure that the right package is installed, and ldconfig didn't find it, it may just be in a nonstandard directory. By default, ldconfig looks in /lib, /usr/lib, and directories listed in /etc/ld.so.conf and $LD_LIBRARY_PATH. If your library is somewhere else, you can either add the directory on its own line in /etc/ld.so.conf, append the library's path to $LD_LIBRARY_PATH, or move the library into /usr/lib. Then run ldconfig.

To find out where the library is, try this:

sudo find / -iname *libraryname*.so*

(Replace libraryname with the name of your library)

If you go the $LD_LIBRARY_PATH route, you'll want to put that into your ~/.bashrc file so it will run every time you log in:

export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/path/to/library
Discussions

cannot open shared object file: No such file or directory
SOLVED The library needs to be aided to BOTH main project and sub project where it is used. The error indicated which project is missing the access to the li... More on forum.qt.io
🌐 forum.qt.io
3
0
December 22, 2022
[Solved] libCore.so: cannot open shared object file: No such
Hi everyone, I recently encountered an error that I was struggling with and have finally solved it. I'm not sure if this solution is explicitly detailed in the documentation, I'm simply posting the solution here so in ca… More on root-forum.cern.ch
🌐 root-forum.cern.ch
6
0
June 14, 2011
Cannot open shared object file: No such file or directory... part 2
I have followed the instructions from issue and still have: /tmp/go-build1465283250/b001/exe/main: error while loading shared libraries: libtensorflowlite_c.so: cannot open shared object file: No s... More on github.com
🌐 github.com
4
January 28, 2022
error while loading shared libraries: libjxl.so.0.7: cannot open shared object file: No such file or directory
libjxl is not even a dependency of mpv? https://archlinux.org/packages/community/x86_64/mpv/ (Also, I have community/mpv on my machine and no libjxl at all) More on reddit.com
🌐 r/archlinux
14
6
February 21, 2023
🌐
Baeldung
baeldung.com › home › files › solving the “cannot open shared object file: no such file or directory” error in linux
Solving The “Cannot Open Shared Object File: No Such File Or Directory” Error In Linux | Baeldung on Linux
January 14, 2026 - Additionally, if we don’t know where the library is, we can locate it using the find command in common paths such as /home or /usr: $ find /home -type f -name libfoo.so /home/baeldung/libs/libfoo.so · We can use the /etc/ld.so.conf file to permanently set the library search path. In this file, we specify a newline-separated list of directories. ... $ ./program ./program: error while loading shared libraries: libfoo.so: cannot open shared object file: No such file or directory $ echo "/home/baeldung/libs" | sudo tee /etc/ld.so.conf /home/baeldung/libs $ sudo ldconfig $ ldd ./program ./program: linux-vdso.so.1 (0x00007ffefc3db000) libfoo.so => /home/baeldung/libs/libfoo.so (0x00007f021e88d000) libc.so.6 => /usr/lib/libc.so.6 (0x00007f021e674000) /lib/ld-linux-x86-64.so.2 => /usr/lib/ld-linux-x86-64.so.2 (0x00007f021e89e000)
🌐
It's FOSS
itsfoss.com › solve-open-shared-object-file-quick-tip
[Solved] cannot open shared object file Error in Ubuntu
April 16, 2023 - Complete detailed solution for fixing “error while loading shared libraries” error in Ubuntu-based Linux distributions.
🌐
CERN
root-forum.cern.ch › t › solved-libcore-so-cannot-open-shared-object-file-no-such › 12593
[Solved] libCore.so: cannot open shared object file: No such - ROOT - ROOT Forum
June 14, 2011 - I’m not sure if this solution ... shared object file: No such file or directory The problem is that the shared libraries need to be explicitly declared....
🌐
GitHub
github.com › mattn › go-tflite › issues › 42
Cannot open shared object file: No such file or directory... part 2 · Issue #42 · mattn/go-tflite
January 28, 2022 - I have followed the instructions from issue and still have: /tmp/go-build1465283250/b001/exe/main: error while loading shared libraries: libtensorflowlite_c.so: cannot open shared object file: No such file or directory exit status 127 I ...
Author   mattn
Find elsewhere
🌐
AllThings
allthings.how › all things how › windows › how to fix “error while loading shared libraries: cannot open shared object file: no such file or directory”
How to Fix “error while loading shared libraries: cannot open shared object file: No such file or directory”
April 4, 2025 - The error while loading shared libraries: cannot open shared object file: No such file or directory message typically occurs when Linux programs can’t locate the required shared library (.so) files at runtime.
🌐
GitHub
github.com › opentoonz › opentoonz › issues › 5015
error while loading shared libraries: cannot open shared object file: No such file or directory · Issue #5015 · opentoonz/opentoonz
July 13, 2023 - get that error (also from terminal too) ~$ opentoonz /usr/bin/../bin/OpenToonz: error while loading shared libraries: libopencv_videoio.so.408: cannot open shared object file: No such file or directory
Author   opentoonz
🌐
Unraid
forums.unraid.net › home › unraid os support › general support › `libselinux.so.1: cannot open shared object file: no such file or directory` in terminal
`libselinux.so.1: cannot open shared object file: No such file or directory` in terminal - General Support - Unraid
June 24, 2025 - Fairly fresh install. Everything is up-to-date. Recently have migrated from Proxmox and loving Unraid so far. However, I get the message: id: error while loading shared libraries: libselinux.so.1: cannot open shared object file: No such file or directory whenever I open the terminal for the syste...
🌐
GitHub
github.com › intel › llvm › issues › 6301
cannot open shared object file : No such file or directory · Issue #6301 · intel/llvm
June 14, 2022 - Describe the bug build intel/llvm compile cuda toolchain in release tag version[2021-12] and reference discussion here #4926 to revise source files. There is a workaround which proposes to comment out 3-4 lines here llvm/sycl/source/CMak...
Author   intel
🌐
Windows Report
windowsreport.com › fix › cannot open shared object no such file or directory [fix]
Cannot Open Shared Object no Such File or Directory [Fix]
October 4, 2024 - Cannot open a shared object no such file or directory occurs due to missing packages, but this guide can help you fix it in no time.
🌐
Reddit
reddit.com › r/learnprogramming › libsdl3.so.0: cannot open shared object file: no such file or directory
r/learnprogramming on Reddit: libSDL3.so.0: cannot open shared object file: No such file or directory
December 8, 2024 -

I am trying to compile this example code from SDL's own github.

My "makefile" (actually just a bash file) looks like this: gcc -O -Wall -W -pedantic --std=c17 -o game main.c -lSDL3 -lm

It compiles fine, so I guess my installation of SDL3 was successful. The CMake script put it in /usr/local/ instead of just /usr/ where apt put SDL2.

libSDL3.so.0 is in here:

/usr/local/lib$ ls -a
.   cmake       libSDL3.so.0      libSDL3_test.a  python3.10
..  libSDL3.so  libSDL3.so.0.1.3  pkgconfig

The weird thing though is that libSDL3.so is a link to libSDL.so.0, which in turn is a link to libSDL.so.0.1.3 which are all in the same folder... I have no idea what that is good for, but then again, I am a newb.

What should I do? I found a similar problem someone had with SDL2 back in the day, on SO, but I don't really understand that thread.

Thankful for any support!

🌐
Ars OpenForum
arstechnica.com › forums › operating systems & software › linux kung fu
[Solved] Error while loading shared libraries: file not found even though it exists | Ars OpenForum
August 22, 2023 - Solution: SELinux was interferring, and a reinstall of RHEL without using SELinux resolved the problem. I get the following error that a shared is not found, even though it exists, is in the library path, and ldd knows where the file is: /usr/local/XXX/Linux64/bin/.myprog: error while loading...
🌐
Arch Linux Forums
bbs.archlinux.org › viewtopic.php
cannot open shared object file: No such file or directory / Newbie Corner / Arch Linux Forums
January 23, 2018 - I'm not sure but error message 'cannot open shared object file: No such file or directory' was common. I googled and found 'sudo /sbin/ldconfig -v' will work but in my case doesn't work. ... Most of the "No such file or directory" errors you're seeing is because of optional deps for plugins.
🌐
Red Hat
access.redhat.com › solutions › 5149341
Services are failing with: "cannot open shared object file: No such file or directory" - Red Hat Customer Portal
June 14, 2024 - Jun 09 13:39:57 controller1.example.com aliasesdb[839363]: /usr/sbin/postconf: error while loading shared libraries: libmysqlclient.so.18: cannot open shared object file: No such...r directory Jun 09 13:39:57 controller1.example.com aliasesdb[839363]: /usr/bin/newaliases: error while loading shared libraries: libmysqlclient.so.18: cannot open shared object file: No suc...r directory Jun 09 13:39:57 controller1.example.com postfix[839371]: /usr/sbin/postfix: error while loading shared libraries: libmysqlclient.so.18: cannot open shared object file: No such fi...r directory Jun 09 13:39:57 controller1.example.com systemd[1]: postfix.service: control process exited, code=exited status=127 Jun 09 13:39:57 controller1.example.com systemd[1]: Failed to start Postfix Mail Transport Agent.
🌐
Arch Linux Forums
bbs.archlinux.org › viewtopic.php
[SOLVED] Cannot open shared object file: No such file or directory / Newbie Corner / Arch Linux Forums
August 9, 2016 - pacman -R gnutls error: could not open file /var/lib/pacman/local/gnutls-3.4.14-1/desc: No such file or directory warning: could not fully load metadata for package gnutls-3.4.14-1 checking dependencies...