Creating a shared object library: ldd does not show the specified name

I am trying to create a shared object library in Debian

cat /etc/issue
Debian GNU/Linux 9 \n \l

I build the library and the object as usual ( wrap.cserves as a wrapper for creating all the object files)

gcc -c -fPIC -W -Wall -O2 -funroll-loops wrap.c
gcc -shared -Wl,-soname,libtest.so -o libtest.so *.o
mv libtest.so /usr/local/lib/ && mv test-header.h /usr/local/include/

Then I create test.cto pull out the library and compile it as follows:

gcc test.c -ltest

However, when the program starts, the ./a.outfollowing error is returned:

./a.out: error loading shared libraries: libtest.so: cannot open shared objects file: no such file or directory

Checking .so, I see:

$ ldd /path/to/libtest.so
    linux-vdso.so.1 (0x00007ffdb71c5000)
    libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f1c22fba000)
    /lib64/ld-linux-x86-64.so.2 (0x00007f1c23560000)

I don’t even see libtest.so => nonewho, at least, would tell me that he cannot find the library.

I'm not quite sure what is going on here.

.dylib macOS ( gcc -dynamiclib -o libtest.dylib *.o), . , Debian.

+4
1

libtest.so, /usr/local/lib

gcc test.c -ltest

/usr/local/lib - .

./a.out, , , LD_LIBRARY_PATH, , . ldconfig , ldconfig ( root).

, , : -

:

export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/lib; ./a.out

:

sudo ldconfig

.

, ldd /path/to/libtest.so , , libtest.so. , ./a.out /path/to/libtest.so. a.out, ldd a.out

+2

Source: https://habr.com/ru/post/1685697/


All Articles