Gcc
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)
dlopen
通常由 提供libdl.so.2
。在 Arch Linuxlibdl.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