Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Linux error while loading shared libraries: cannot open shared object file: No such file or directory

Program is part of the Xenomai test suite, cross-compiled from Linux PC into Linux+Xenomai ARM toolchain.

# echo $LD_LIBRARY_PATH                                                                                                                                           /lib                                                                                                                                                              # ls /lib                                                                                                                                                         ld-2.3.3.so         libdl-2.3.3.so      libpthread-0.10.so                                                                                                        ld-linux.so.2       libdl.so.2          libpthread.so.0                                                                                                           libc-2.3.3.so       libgcc_s.so         libpthread_rt.so                                                                                                          libc.so.6           libgcc_s.so.1       libstdc++.so.6                                                                                                            libcrypt-2.3.3.so   libm-2.3.3.so       libstdc++.so.6.0.9                                                                                                        libcrypt.so.1       libm.so.6                                                                                                                                     # ./clocktest                                                                                                                                                     ./clocktest: error while loading shared libraries: libpthread_rt.so.1: cannot open shared object file: No such file or directory                                  

Edit: OK I didn't notice the .1 at the end was part of the filename. What does that mean anyway?

like image 775
zaratustra Avatar asked Jan 26 '09 18:01

zaratustra


People also ask

How do you fix Cannot open shared object file no such file or directory?

Fix ing 'cannot open shared object file: No such file or directory' error. One quick way to fix this “error while loading shared libraries” automatically is to use ldconfig. This one liner should solve the problem in most cases.

How do I open a shared library file?

If you want to open a shared-library file, you would open it like any other binary file -- with a hex-editor (also called a binary-editor). There are several hex-editors in the standard repositories such as GHex (https://packages.ubuntu.com/xenial/ghex) or Bless (https://packages.ubuntu.com/xenial/bless).

How do I open a .so file?

so file is a binary file used as a native library on Android. Normally it's a part of an Android application. If you want to see its content, you need to open it as a binary file in a binary (hex) viewer. In any case you won't see much there, but hex code.


1 Answers

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 
  1. 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 
  1. 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 :

$ LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/my_library/ $ export LD_LIBRARY_PATH $ ./my_app 

Reference to source

like image 153
XOR Avatar answered Sep 22 '22 06:09

XOR