libtreeldd 转为树结构
libtree 可将 ldd 命令作为树结构呈现,可选择将可执行文件和依赖项部署到单个目录中。( ldd 全称 list - dynamic - dependencies,用于在 Linux 中打印程序或者库文件所依赖的共享库列表)
安装
静态可执行文件
wget -qO libtree https://github.com/haampie/libtree/releases/download/v2.0.0/libtree_x86_64
chmod +x libtree
./libtree $( which man )
静态可执行文件 + 可选依赖项
wget -qO libtree.tar.gz https://github.com/haampie/libtree/releases/download/v2.0.0/libtree_x86_64.tar.gz
mkdir libtree
tar -xf libtree.tar.gz -C libtree export PATH= " $PWD /libtree: $PATH "
libtree $( which man )
将二进制文件 + 依赖项部署到文件夹中
$ libtree $(which man) -d man.bundle --chrpath --strip
man
├── libmandb-2.9.1.so [runpath]
│ ├── libman-2.9.1.so [runpath]
│ │ ├── libpipeline.so.1 [ld.so.conf]
│ │ └── libseccomp.so.2 [ld.so.conf]
│ └── libgdbm.so.6 [ld.so.conf]
├── libman-2.9.1.so (collapsed) [runpath]
└── libpipeline.so.1 (collapsed) [ld.so.conf]
Deploying to "man.bundle/usr"
"/usr/bin/man" => "man.bundle/usr/bin/man"
"/usr/lib/man-db/libmandb-2.9.1.so" => "man.bundle/usr/lib/libmandb-2.9.1.so"
"/usr/lib/man-db/libman-2.9.1.so" => "man.bundle/usr/lib/libman-2.9.1.so"
"/usr/lib/x86_64-linux-gnu/libpipeline.so.1.5.2" => "man.bundle/usr/lib/libpipeline.so.1.5.2"
creating symlink "man.bundle/usr/lib/libpipeline.so.1"
"/usr/lib/x86_64-linux-gnu/libseccomp.so.2.5.1" => "man.bundle/usr/lib/libseccomp.so.2.5.1"
creating symlink "man.bundle/usr/lib/libseccomp.so.2"
"/usr/lib/x86_64-linux-gnu/libgdbm.so.6.0.0" => "man.bundle/usr/lib/libgdbm.so.6.0.0"
creating symlink "man.bundle/usr/lib/libgdbm.so.6"
$ tree man.bundle/
man.bundle/
└── usr
├── bin
│ └── man
└── lib
├── libgdbm.so.6 -> libgdbm.so.6.0.0
├── libgdbm.so.6.0.0
├── libman-2.9.1.so
├── libmandb-2.9.1.so
├── libpipeline.so.1 -> libpipeline.so.1.5.2
├── libpipeline.so.1.5.2
├── libseccomp.so.2 -> libseccomp.so.2.5.1
└── libseccomp.so.2.5.1
3 directories, 9 files
详细输出
默认情况下, libtree 不显示标准依赖项,对于更详细的输出,可以使用
-
libtree -v $(which man)
显示跳过的没有子库的图书馆 -
libtree -a $(which apt-get)
显示库的完整递归列表
使用--path
或者-p
标志来显示路径:
libtree -p $(which tar)
更改搜索路径
Libtree 遵循 ld.so 的规则来定位库,但不使用 ldconfig 的缓存,相反,它在运行时解析/etc/ld.so.conf,可以通过设置—— ldconf mylibs.conf 来更改搜索路径配置。也可以通过 LD_LIBRARY_PATH="path1:path2:$LD_LIBRARY_PATH" libtree .... 添加搜索路径。
评论