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 do I do?
The "shared library gone missing" problem is not unique to libsandbox
. It so happens to many self-compiled libraries that use GNU autotools for build configuration.
The problem is that GNU autotools prepares the library to go to /usr/local/lib
by default (and there are good reasons for this setting to remain default, such as FHS conformance). However, in some Linux distributions -- like Ubuntu and ArchLinux -- the runtime linker (aka. ld.so
) does not search /usr/local/lib
for shared libraries, unless otherwise specified through ldconfig
.
While all other solutions from @anton-kovalenko's answer are viable, it could be more convenient if you just configure libsandbox
with options --prefix=/usr
and --libdir=/usr/lib
(in case you have write access to /usr/lib
, of course). Or you can add a new ldconfig
entry in /etc/ld.so.conf.d
to enable /usr/local/lib
for library search at system level.
DISCLAIMER: I am the author of libsandbox
.