我在 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)
dlopen
通常由 提供libdl.so.2
。在 Arch Linuxlibdl.so.2
上是由glibc
包提供的。如果您没有glibc
安装会很奇怪,但无论如何,请检查libdl.so.2
您的系统上是否有。您还可以使用
readelf
命令输出共享对象的符号表并检查是否导出了特定符号:ldd
可以在此处找到有关为什么相同二进制文件的输出在不同系统上可能不同的一些信息:https://stackoverflow.com/questions/12714219/ldd-different-output-same-binary-different-distros