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.c
serves 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.c
to pull out the library and compile it as follows:
gcc test.c -ltest
However, when the program starts, the ./a.out
following 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 => none
who, 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.