Error loading shared libraries: libsandbox.so

When I try to run the .out file after compiling the sandbox c program, it gives the following error:

    ./sandbox: error while loading shared libraries: libsandbox.so: cannot open shared object file: No such file or directory

      

What should I do?

+3


source to share


2 answers


The " lost " problem is not unique to libsandbox

. This is the case with many self-compiling libraries that use GNU autotools for build configuration.

The problem is that GNU autotools prepares the library for /usr/local/lib

the default (and there are good reasons for keeping this setting as default, such as FHS compliance). However, on some Linux distributions such as Ubuntu and ArchLinux , the runtime linker (aka. ld.so

) Does not search /usr/local/lib

for shared libraries unless otherwise specified via ldconfig

.



While all of the other solutions from @ anton-kovalenko's answer are viable, it would be more convenient if you just configure libsandbox

with parameters --prefix=/usr

and --libdir=/usr/lib

(if you have write access to /usr/lib

, from the course). Or, you can add a new entry ldconfig

in /etc/ld.so.conf.d

to enable /usr/local/lib

system-level search libraries.

DISCLAIMER: I am the author libsandbox

.

+5


source


You do the following:



  • You will first discover where it is copied libsandbox.so

    . This is probably the place if you've successfully contacted it.
  • Then you try to use env LD_LIBRARY_PATH=/directory/of/your/libsandbox/copy/ ./sandbox

    and see if it works.
  • Then you decide how to deploy your program along with the library so that it works on the target machine. There are many possibilities: gcc -Wl,-rpath='$ORIGIN'

    for linking it will make it libsandbox.so

    bootable from an executable directory. Another solution is a wrapper script that takes care of LD_LIBRARY_PATH

    . Place libsandbox.so

    in a location where the dynamic linker can find another.
+1


source







All Articles