linux 查看库依赖

PC Linux上查看库依赖依赖关系

直接使用ldd 命令即可,可以查看可执行程序,比如:

root@forlinx:~# ldd /bin/mv
linux-gate.so.1 =>  (0x00c7b000)
libselinux.so.1 => /lib/i386-linux-gnu/libselinux.so.1 (0x00136000)
librt.so.1 => /lib/i386-linux-gnu/librt.so.1 (0x00ada000)
libacl.so.1 => /lib/i386-linux-gnu/libacl.so.1 (0x00fac000)
libattr.so.1 => /lib/i386-linux-gnu/libattr.so.1 (0x005ae000)
libc.so.6 => /lib/i386-linux-gnu/libc.so.6 (0x00151000)
libdl.so.2 => /lib/i386-linux-gnu/libdl.so.2 (0x006b1000)
/lib/ld-linux.so.2 (0x00578000)
libpthread.so.0 => /lib/i386-linux-gnu/libpthread.so.0 (0x00302000)
root@forlinx:~#

也可以查看动态库 比如:

root@forlinx:~# ldd /lib/libcrypto.so.0.9.8 
linux-gate.so.1 =>  (0x00a88000)
libdl.so.2 => /lib/i386-linux-gnu/libdl.so.2 (0x00d04000)
libz.so.1 => /lib/i386-linux-gnu/libz.so.1 (0x001b9000)
libc.so.6 => /lib/i386-linux-gnu/libc.so.6 (0x001ce000)
/lib/ld-linux.so.2 (0x00886000)


查看嵌入式平台上,交叉编译好的可执行程序,或者库文件的相关依赖

在PC Linux上执行命令:arm-linux-readelf  -a "your binary" | grep "Shared"

例如查看二进制可执行文件:
root@forlinx:~# arm-linux-readelf  -a "/mnt/Linux/FileSystem-Yaffs2/bin/ls" | grep "Shared"
 0x00000001 (NEEDED)                     Shared library: [libm.so.6]
 0x00000001 (NEEDED)                     Shared library: [libc.so.6]

查看动态库文件:

root@forlinx:~# arm-linux-readelf  -a "/mnt/Linux/FileSystem-Yaffs2/lib/libresolv.so.2" | grep "Shared"
  Type:                              DYN (Shared object file)
 0x00000001 (NEEDED)                     Shared library: [libc.so.6]
root@forlinx:~#


你可能感兴趣的:(linux 查看库依赖)