ldd 用于分析 ubuntu 中软件的缺失公共库

ldd 是什么

用于显示共享对象依赖项。

DESCRIPTION

       ldd prints the shared objects (shared libraries) required by each
       program or shared object specified on the command line.  An
       example of its use and output is the following:

           $ ldd /bin/ls
               linux-vdso.so.1 (0x00007ffcc3563000)
               libselinux.so.1 => /lib64/libselinux.so.1 (0x00007f87e5459000)
               libcap.so.2 => /lib64/libcap.so.2 (0x00007f87e5254000)
               libc.so.6 => /lib64/libc.so.6 (0x00007f87e4e92000)
               libpcre.so.1 => /lib64/libpcre.so.1 (0x00007f87e4c22000)
               libdl.so.2 => /lib64/libdl.so.2 (0x00007f87e4a1e000)
               /lib64/ld-linux-x86-64.so.2 (0x00005574bf12e000)
               libattr.so.1 => /lib64/libattr.so.1 (0x00007f87e4817000)
               libpthread.so.0 => /lib64/libpthread.so.0 (0x00007f87e45fa000)

ldd 的用法

用途

以 chromium 为例。

ldd /path/to/chrome | grep 'not found'

得到

        libatk-1.0.so.0 => not found 1
        libatk-bridge-2.0.so.0 => not found 1
        libcups.so.2 => not found 1
        libdrm.so.2 => not found 1
        libdbus-1.so.3 => not found 0
        libatspi.so.0 => not found
        libXcomposite.so.1 => not found
        libXdamage.so.1 => not found
        libXfixes.so.3 => not found
        libXrandr.so.2 => not found
        libgbm.so.1 => not found
        libxkbcommon.so.0 => not found
        libasound.so.2 => not found
root@be1a10622606:/usr/app#

根据找到的 shared library 缺失的内容,然后可以用 apt-get install 命令来安装他们。

apt-get install -y libnss3 libatk1.0-0 libatk-bridge2.0-0 libcups2 libdrm2 libxkbcommon0 libxcomposite1 libxdamage1 libxfixes3 libxrandr2 libgbm1 libasound2 libdbus-1-3

参考链接

  1. ldd(1) — Linux manual page
关于本文如您有任何想法和意见,欢迎与我们联系,邮箱地址zhi@uqugu.com
您对本文有什么看法,喜欢或者不喜欢都可以发表意见。