Linux 中 ldd
(List Dynamic Dependencies
) 可以列出可执行程序的动态库依赖关系,常用来查看可执行程序运行所需的共享库,在解决程序依赖关系中使用的比较多。
help
$ ldd --help
Usage: ldd [OPTION]... FILE...
--help print this help and exit
--version print version information and exit
-d, --data-relocs process data relocations
-r, --function-relocs process data and function relocations
-u, --unused print unused direct dependencies
-v, --verbose print all information
For bug reporting instructions, please see:
<http://www.gnu.org/software/libc/bugs.html>.
demo
查看 Nginx 的动态依赖库:
$ ldd /usr/sbin/nginx
linux-vdso.so.1 => (0x00007ffed8993000)
libdl.so.2 => /lib64/libdl.so.2 (0x00007fad30627000)
libpthread.so.0 => /lib64/libpthread.so.0 (0x00007fad3040b000)
libcrypt.so.1 => /lib64/libcrypt.so.1 (0x00007fad301d4000)
libpcre.so.1 => /lib64/libpcre.so.1 (0x00007fad2ff72000)
libssl.so.1.1 => /lib64/libssl.so.1.1 (0x00007fad2fce2000)
libcrypto.so.1.1 => /lib64/libcrypto.so.1.1 (0x00007fad2f7ff000)
libz.so.1 => /lib64/libz.so.1 (0x00007fad2f5e9000)
libprofiler.so.0 => /lib64/libprofiler.so.0 (0x00007fad2f3d5000)
libc.so.6 => /lib64/libc.so.6 (0x00007fad2f008000)
/lib64/ld-linux-x86-64.so.2 (0x00007fad30b70000)
libfreebl3.so => /lib64/libfreebl3.so (0x00007fad2ee05000)
libstdc++.so.6 => /lib64/libstdc++.so.6 (0x00007fad2eafe000)
libm.so.6 => /lib64/libm.so.6 (0x00007fad2e7fc000)
libgcc_s.so.1 => /lib64/libgcc_s.so.1 (0x00007fad2e5e6000)