building a shared object library: ldd does not show specified name

Viewed 2515

I'm trying to build a shared object library on Debian

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

I build the library and object as normal (wrap.c serves as a wrapper to create all 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/

I then create a test.c to pull in the library and compile successfully as follows:

gcc test.c -ltest

However, running the program ./a.out returns the following error:

./a.out: error while loading shared libraries: libtest.so: cannot open shared object file: No such file or directory

Inspecting the .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 => none, which at least would tell me it can't find the library.

I'm not really sure what's going on here.

I am to successfully create a .dylib on macOS with the same process (with gcc -dynamiclib -o libtest.dylib *.o), and I can successfully call the library in an executable. I'm not sure what's different on Debian.

1 Answers
Related