I wrote a shared library named "libmyssl.so", I use some openssl function in my code, the make file looks like follows:
g++ -v -shared -lz -lssl -lcrypto -Wl,-soname,libmyssl.so.1,-o libmyssl.so.1.0 myssl.o
After that, I use ldd command to look if it depends on libssl.so:
ldd libmyssl.so.1.0
The result as follows:
linux-vdso.so.1 => (0x00007fff743fe000)
libstdc++.so.6 => /usr/lib/x86_64-linux-gnu/libstdc++.so.6 (0x00007f0bc963b000)
libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f0bc9276000)
libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007f0bc8f6f000)
/lib64/ld-linux-x86-64.so.2 (0x00007f0bc9ea0000)
libgcc_s.so.1 => /lib/x86_64-linux-gnu/libgcc_s.so.1 (0x00007f0bc8d59000)
It seems it didn't depend on libssl.so, am I right?
However, I use readelf -s command to see the symbols as follows:
readelf -s libmyssl.so.1.0
The reasult as follow:
......
259: 0000000000000000 0 NOTYPE GLOBAL DEFAULT UND SSL_new
260: 0000000000000000 0 NOTYPE GLOBAL DEFAULT UND SSL_get_shutdown
261: 0000000000000000 0 FUNC GLOBAL DEFAULT UND close@GLIBC_2.2.5 (4)
262: 0000000000000000 0 NOTYPE GLOBAL DEFAULT UND d2i_X509
263: 0000000000000000 0 NOTYPE GLOBAL DEFAULT UND X509_get_pubkey
264: 0000000000000000 0 NOTYPE GLOBAL DEFAULT UND SSL_set_info_callback
265: 0000000000000000 0 FUNC GLOBAL DEFAULT UND gmtime_r@GLIBC_2.2.5 (4)
......
It seems that the X509_get_putkey is not relocated. So it should depend on libssl.so. Maybe I didn't understand it well.
Hope someone can explain more about that, thanks very much!
A program would typically depend on other libraries to function. These libraries could either be compiled into the program itself or loaded from a shared library pool. The use of shared libraries reduces the program size and eases the development and distribution of the program. In Linux, shared libraries are stored in /lib* or /usr/lib* .
You will get the following error when the required library is not available in the system. You can check the shared libraries that a program depends on using ldd or other command-line tools to troubleshoot shared libraries loading issues. Launch your preferred terminal application. Get absolute path of the program you want to check.
Different Linux distributions or even versions of the same distribution might package different libraries, making a program compiled for a particular distribution or version not correctly run on another. You will get the following error when the required library is not available in the system.
Some distributions would require you to list linked libraries after object files that reference them (to mimic how static libs work). So try to build like:
g++ -v -shared -Wl,-soname,libmyssl.so.1,-o libmyssl.so.1.0 myssl.o -lz -lssl -lcrypto
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With