ldd 中缺少共享库

ldd 中缺少共享库

我在 CentOS 6.x 上编译了 Apache httpd。在那里运行良好。

然后我将二进制文件移到 CentOS 7。我需要安装一些缺少的库,现在在那里运行良好。

然后我将二进制文件移到 Archlinux。正如我所料,它没有直接启动:

httpd: symbol lookup error: /software_pack/httpd-2.2.25/lib/libapr-1.so.0: undefined symbol: dlopen

但是,如果我ldd /software_pack/httpd-2.2.25/lib/libapr-1.so.0这样做,在 CentOS 和 Archlinux 上会出现不同的结果。在 Archlinux 上,libdl.so 根本不显示?

CentOS 从哪里知道该文件需要 libdl.so.2?

CentOS 6.x:

# ls -la /software_pack/httpd-2.2.25/lib/libaprutil-1.so.0
lrwxrwxrwx 1 root root 21 Jul 30 09:47 /software_pack/httpd-2.2.25/lib/libaprutil-1.so.0 -> libaprutil-1.so.0.5.2
# ldd /software_pack/httpd-2.2.25/lib/libaprutil-1.so.0.5.2
        linux-vdso.so.1 =>  (0x00007fffec400000)
        libexpat.so.0 => /software_pack/httpd-2.2.25/lib/libexpat.so.0 (0x00007f5ec94d8000)
        libapr-1.so.0 => /software_pack/httpd-2.2.25/lib/libapr-1.so.0 (0x00007f5ec92a8000)
        librt.so.1 => /lib64/librt.so.1 (0x00007f5ec9098000)
        libcrypt.so.1 => /lib64/libcrypt.so.1 (0x00007f5ec8e60000)
        libpthread.so.0 => /lib64/libpthread.so.0 (0x00007f5ec8c40000)
        libc.so.6 => /lib64/libc.so.6 (0x00007f5ec88a8000)
        /lib64/ld-linux-x86-64.so.2 (0x00007f5ec9928000)
        libfreebl3.so => /lib64/libfreebl3.so (0x00007f5ec8630000)
        libdl.so.2 => /lib64/libdl.so.2 (0x00007f5ec8428000)   <<<<<<<< Missing in arch

在 Archlinux 上:

# ls -la /software_pack/httpd-2.2.25/lib/libaprutil-1.so.0
lrwxrwxrwx 1 root root 21 Jul 30 10:47 /software_pack/httpd-2.2.25/lib/libaprutil-1.so.0 -> libaprutil-1.so.0.5.2
# ldd /software_pack/httpd-2.2.25/lib/libaprutil-1.so.0.5.2
        linux-vdso.so.1 (0x00007fff7cdd3000)
        libexpat.so.0 => /software_pack/httpd-2.2.25/lib/libexpat.so.0 (0x00007f5aef4e7000)
        libapr-1.so.0 => /software_pack/httpd-2.2.25/lib/libapr-1.so.0 (0x00007f5aef2ba000)
        librt.so.1 => /usr/lib/librt.so.1 (0x00007f5aef084000)
        libcrypt.so.1 => /usr/lib/libcrypt.so.1 (0x00007f5aeee4b000)
        libpthread.so.0 => /usr/lib/libpthread.so.0 (0x00007f5aeec2d000)
        libc.so.6 => /usr/lib/libc.so.6 (0x00007f5aee87f000)
        /usr/lib64/ld-linux-x86-64.so.2 (0x00007f5aef934000)

答案1

dlopen通常由 提供libdl.so.2。在 Arch Linux 上libdl.so.2由软件包提供glibc。如果您没有安装,那会很奇怪,但无论如何,请检查您的系统上glibc是否有。libdl.so.2

您还可以使用readelf命令输出共享对象的符号表并检查是否导出特定符号:

readelf -Ws /usr/lib/libdl.so.2

关于为什么ldd相同二进制文件的输出在不同系统上可能不同的一些信息可以在这里找到:

https://stackoverflow.com/questions/12714219/ldd-different-output-same-binary-different-distros

相关内容