Libtree: Turns ldd into a tree; explains why shared libraries are found or not

101
Libtree: Turns ldd into a tree; explains why shared libraries are found or not

Test
AUR version

A tool that:

  • 🌳 turns ldd into a tree
  • ☝️ explains why shared libraries are found and why not
  • 📦 optionally deploys executables and dependencies into a single directory

example

Installation

Download the latest release from Github.

Static executable

wget -qO libtree https://github.com/haampie/libtree/releases/download/v2.0.0/libtree_x86_64
chmod +x libtree
./libtree $(which man)

Static executable + optional dependencies

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)

Deploying binaries + dependencies into a folder

“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 $(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

Verbose output

By default certain standard depenendencies are not shown. For more verbose output use

  • libtree -v $(which man) to show skipped libraries without their children
  • libtree -a $(which apt-get) to show the full recursive list of libraries

Use the --path or -p flags to show paths rather than sonames:

  • libtree -p $(which tar)

Changing search paths

libtree follows the rules of ld.so to locate libraries, but does not use ldconfig‘s
cac

Read More

Knowasiak
WRITTEN BY

Knowasiak

Hey! look, i give tutorials to all my users and i help them!