Linux系统实用工具——ldd

2024-03-26 23:18
文章标签 linux 系统 实用工具 ldd

本文主要是介绍Linux系统实用工具——ldd,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!

看你缺点啥——ldd

一、ldd是什么?

ldd(list dynamic dependencies),列出动态库依赖关系。 ldd不是个可执行程式,而只是个shell脚本。 ldd显示可执行模块的dependency的工作原理,其实质是通过ld-linux.so(elf动态库的装载器)来实现的。ld-linux.so模块会先于executable模块程式工作,并获得控制权,因此当上述的那些环境变量被设置时,ld-linux.so选择了显示可执行模块的dependency。

二、ldd能做什么?

用来查看程式运行所需的共享库,常用来解决程式因缺少某个库文件而不能运行的一些问题。

三、ldd怎么使用?

ldd打印命令行中指定的每个程序或共享库所需的共享库。

Usage: ldd [OPTION]... FILE...--help              print this help and exit--version           print version information and exit-d, --data-relocs       process data relocations-r, --function-relocs   process data and function relocations-u, --unused            print unused direct dependencies-v, --verbose           print all informationFor bug reporting instructions, please see:
<http://www.gnu.org/software/libc/bugs.html>.
OPTIONS--versionPrint the version number of ldd.-v --verbosePrint all information, including, for example, symbol versioning information.-u --unusedPrint unused direct dependencies.  (Since glibc 2.3.4.)-d --data-relocsPerform relocations and report any missing objects (ELF only).-r --function-relocsPerform relocations for both data objects and functions, and report any missing objects or functions (ELF only).--help Usage information.
$ ldd --version
ldd (GNU libc) 2.12
Copyright (C) 2010 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
由 Roland McGrath 和 Ulrich Drepper 编写。
$ ldd extest.so linux-vdso.so.1 =>  (0x00007fff153ff000)libdl.so.2 => /lib64/libdl.so.2 (0x00007f35bb58a000)libssl.so.10 => /usr/lib64/libssl.so.10 (0x00007f35bb32f000)libpthread.so.0 => /lib64/libpthread.so.0 (0x00007f35bb112000)libstdc++.so.6 => /usr/lib64/libstdc++.so.6 (0x00007f35bae0b000)libm.so.6 => /lib64/libm.so.6 (0x00007f35baa75000)libgcc_s.so.1 => /lib64/libgcc_s.so.1 (0x00007f35ba85e000)libc.so.6 => /lib64/libc.so.6 (0x00007f35ba4cb000)/lib64/ld-linux-x86-64.so.2 (0x0000003421c00000)libgssapi_krb5.so.2 => /lib64/libgssapi_krb5.so.2 (0x00007f35ba287000)libkrb5.so.3 => /lib64/libkrb5.so.3 (0x00007f35b9fa0000)libcom_err.so.2 => /lib64/libcom_err.so.2 (0x00007f35b9d9c000)libk5crypto.so.3 => /lib64/libk5crypto.so.3 (0x00007f35b9b70000)libcrypto.so.10 => /usr/lib64/libcrypto.so.10 (0x00007f35b97d5000)libz.so.1 => /lib64/libz.so.1 (0x00007f35b95bf000)libnsl.so.1 => /lib64/libnsl.so.1 (0x00007f35b93a6000)librt.so.1 => /lib64/librt.so.1 (0x00007f35b919d000)libkrb5support.so.0 => /lib64/libkrb5support.so.0 (0x00007f35b8f92000)libkeyutils.so.1 => /lib64/libkeyutils.so.1 (0x00007f35b8d8f000)libresolv.so.2 => /lib64/libresolv.so.2 (0x00007f35b8b74000)libselinux.so.1 => /lib64/libselinux.so.1 (0x00007f35b8955000)$ ldd -u extest.so 
Unused direct dependencies:/home/tangf//appcom/libZCEFTDAPI.so/lib64/libdl.so.2/usr/lib64/libssl.so.10/lib64/libpthread.so.0/lib64/libm.so.6/lib64/libgcc_s.so.1$ ldd -d extest.so linux-vdso.so.1 =>  (0x00007fff153ff000)libdl.so.2 => /lib64/libdl.so.2 (0x00007f35bb58a000)libssl.so.10 => /usr/lib64/libssl.so.10 (0x00007f35bb32f000)libpthread.so.0 => /lib64/libpthread.so.0 (0x00007f35bb112000)libstdc++.so.6 => /usr/lib64/libstdc++.so.6 (0x00007f35bae0b000)libm.so.6 => /lib64/libm.so.6 (0x00007f35baa75000)libgcc_s.so.1 => /lib64/libgcc_s.so.1 (0x00007f35ba85e000)libc.so.6 => /lib64/libc.so.6 (0x00007f35ba4cb000)/lib64/ld-linux-x86-64.so.2 (0x0000003421c00000)libgssapi_krb5.so.2 => /lib64/libgssapi_krb5.so.2 (0x00007f35ba287000)libkrb5.so.3 => /lib64/libkrb5.so.3 (0x00007f35b9fa0000)libcom_err.so.2 => /lib64/libcom_err.so.2 (0x00007f35b9d9c000)libk5crypto.so.3 => /lib64/libk5crypto.so.3 (0x00007f35b9b70000)libcrypto.so.10 => /usr/lib64/libcrypto.so.10 (0x00007f35b97d5000)libz.so.1 => /lib64/libz.so.1 (0x00007f35b95bf000)libnsl.so.1 => /lib64/libnsl.so.1 (0x00007f35b93a6000)librt.so.1 => /lib64/librt.so.1 (0x00007f35b919d000)libkrb5support.so.0 => /lib64/libkrb5support.so.0 (0x00007f35b8f92000)libkeyutils.so.1 => /lib64/libkeyutils.so.1 (0x00007f35b8d8f000)libresolv.so.2 => /lib64/libresolv.so.2 (0x00007f35b8b74000)libselinux.so.1 => /lib64/libselinux.so.1 (0x00007f35b8955000)$ ldd -d extest.so | wc -l
23$ ldd extest.so | wc -l
23$ ldd -v extest.so | wc -l
161$ ldd /bin/mvlinux-vdso.so.1 =>  (0x00007fff0a7ff000)libselinux.so.1 => /lib64/libselinux.so.1 (0x0000003423c00000)librt.so.1 => /lib64/librt.so.1 (0x0000003423400000)libacl.so.1 => /lib64/libacl.so.1 (0x000000342f400000)libattr.so.1 => /lib64/libattr.so.1 (0x000000342d000000)libc.so.6 => /lib64/libc.so.6 (0x0000003422400000)libdl.so.2 => /lib64/libdl.so.2 (0x0000003422000000)/lib64/ld-linux-x86-64.so.2 (0x0000003421c00000)libpthread.so.0 => /lib64/libpthread.so.0 (0x0000003422800000)$ ldd /lib64/librt.so.1linux-vdso.so.1 =>  (0x00007fff47ccc000)libc.so.6 => /lib64/libc.so.6 (0x0000003422400000)libpthread.so.0 => /lib64/libpthread.so.0 (0x0000003422800000)/lib64/ld-linux-x86-64.so.2 (0x0000003421c00000)
  • 第一列: 程序需要依赖什么库
  • 第二列: 系统提供的与程序需要的库所对应的库
  • 第三列: 库加载的开始地址

通过对比第一列和第二列,我们可以分析程序需要依赖的库和系统实际提供的,是否相匹配。通过观察第三列,我们可以知道在当前库中的符号在对应进程地址空间中的开始位置。

/lib64/libk5crypto.so.3动态库缺失,对比-d、-r选项和默认选项的区别。

$ ldd extest.so linux-vdso.so.1 =>  (0x00007fffb8bff000)libZCEFTDAPI.so => /home/tangf//appcom/libZCEFTDAPI.so (0x00007fc58f2f6000)libdl.so.2 => /lib64/libdl.so.2 (0x00007fc58f0d3000)libssl.so.10 => /usr/lib64/libssl.so.10 (0x00007fc58ee78000)libpthread.so.0 => /lib64/libpthread.so.0 (0x00007fc58ec5b000)libstdc++.so.6 => /usr/lib64/libstdc++.so.6 (0x00007fc58e954000)libf_os.so => /home/tangf//linux.x64/lib/libf_os.so (0x00007fc58e842000)libm.so.6 => /lib64/libm.so.6 (0x00007fc58e5be000)libgcc_s.so.1 => /lib64/libgcc_s.so.1 (0x00007fc58e3a7000)libc.so.6 => /lib64/libc.so.6 (0x00007fc58e014000)/lib64/ld-linux-x86-64.so.2 (0x0000003421c00000)libgssapi_krb5.so.2 => /lib64/libgssapi_krb5.so.2 (0x00007fc58ddd0000)libkrb5.so.3 => /lib64/libkrb5.so.3 (0x00007fc58dae9000)libcom_err.so.2 => /lib64/libcom_err.so.2 (0x00007fc58d8e5000)libk5crypto.so.3 => not foundlibcrypto.so.10 => /usr/lib64/libcrypto.so.10 (0x00007fc58d54a000)libz.so.1 => /lib64/libz.so.1 (0x00007fc58d334000)libnsl.so.1 => /lib64/libnsl.so.1 (0x00007fc58d11b000)librt.so.1 => /lib64/librt.so.1 (0x00007fc58cf12000)libk5crypto.so.3 => not foundlibkrb5support.so.0 => /lib64/libkrb5support.so.0 (0x00007fc58cd07000)libkeyutils.so.1 => /lib64/libkeyutils.so.1 (0x00007fc58cb03000)libresolv.so.2 => /lib64/libresolv.so.2 (0x00007fc58c8e9000)libk5crypto.so.3 => not foundlibselinux.so.1 => /lib64/libselinux.so.1 (0x00007fc58c6c9000)$ ldd -d extest.so linux-vdso.so.1 =>  (0x00007fffb93d7000)libdl.so.2 => /lib64/libdl.so.2 (0x00007fb45c4c0000)libssl.so.10 => /usr/lib64/libssl.so.10 (0x00007fb45c265000)libpthread.so.0 => /lib64/libpthread.so.0 (0x00007fb45c048000)libstdc++.so.6 => /usr/lib64/libstdc++.so.6 (0x00007fb45bd41000)libm.so.6 => /lib64/libm.so.6 (0x00007fb45b9ab000)libgcc_s.so.1 => /lib64/libgcc_s.so.1 (0x00007fb45b794000)libc.so.6 => /lib64/libc.so.6 (0x00007fb45b401000)/lib64/ld-linux-x86-64.so.2 (0x0000003421c00000)libgssapi_krb5.so.2 => /lib64/libgssapi_krb5.so.2 (0x00007fb45b1bd000)libkrb5.so.3 => /lib64/libkrb5.so.3 (0x00007fb45aed6000)libcom_err.so.2 => /lib64/libcom_err.so.2 (0x00007fb45acd2000)libk5crypto.so.3 => not foundlibcrypto.so.10 => /usr/lib64/libcrypto.so.10 (0x00007fb45a937000)libz.so.1 => /lib64/libz.so.1 (0x00007fb45a721000)libnsl.so.1 => /lib64/libnsl.so.1 (0x00007fb45a508000)librt.so.1 => /lib64/librt.so.1 (0x00007fb45a2ff000)libk5crypto.so.3 => not foundlibkrb5support.so.0 => /lib64/libkrb5support.so.0 (0x00007fb45a0f4000)libkeyutils.so.1 => /lib64/libkeyutils.so.1 (0x00007fb459ef0000)libresolv.so.2 => /lib64/libresolv.so.2 (0x00007fb459cd6000)libk5crypto.so.3 => not foundlibselinux.so.1 => /lib64/libselinux.so.1 (0x00007fb459ab6000)
undefined symbol: krb5int_arcfour_gsscrypt, version k5crypto_3_MIT	(/lib64/libkrb5.so.3)
undefined symbol: krb5int_c_mandatory_cksumtype, version k5crypto_3_MIT	(/lib64/libkrb5.so.3)$ ldd -r extest.so linux-vdso.so.1 =>  (0x00007fffa31ff000)libdl.so.2 => /lib64/libdl.so.2 (0x00007fbc3ec42000)libssl.so.10 => /usr/lib64/libssl.so.10 (0x00007fbc3e9e7000)libpthread.so.0 => /lib64/libpthread.so.0 (0x00007fbc3e7ca000)libstdc++.so.6 => /usr/lib64/libstdc++.so.6 (0x00007fbc3e4c3000)libm.so.6 => /lib64/libm.so.6 (0x00007fbc3e12d000)libgcc_s.so.1 => /lib64/libgcc_s.so.1 (0x00007fbc3df16000)libc.so.6 => /lib64/libc.so.6 (0x00007fbc3db83000)/lib64/ld-linux-x86-64.so.2 (0x0000003421c00000)libgssapi_krb5.so.2 => /lib64/libgssapi_krb5.so.2 (0x00007fbc3d93f000)libkrb5.so.3 => /lib64/libkrb5.so.3 (0x00007fbc3d658000)libcom_err.so.2 => /lib64/libcom_err.so.2 (0x00007fbc3d454000)libk5crypto.so.3 => not foundlibcrypto.so.10 => /usr/lib64/libcrypto.so.10 (0x00007fbc3d0b9000)libz.so.1 => /lib64/libz.so.1 (0x00007fbc3cea3000)libnsl.so.1 => /lib64/libnsl.so.1 (0x00007fbc3cc8a000)librt.so.1 => /lib64/librt.so.1 (0x00007fbc3ca81000)libk5crypto.so.3 => not foundlibkrb5support.so.0 => /lib64/libkrb5support.so.0 (0x00007fbc3c876000)libkeyutils.so.1 => /lib64/libkeyutils.so.1 (0x00007fbc3c672000)libresolv.so.2 => /lib64/libresolv.so.2 (0x00007fbc3c458000)libk5crypto.so.3 => not foundlibselinux.so.1 => /lib64/libselinux.so.1 (0x00007fbc3c238000)
undefined symbol: krb5int_arcfour_gsscrypt, version k5crypto_3_MIT	(/lib64/libkrb5.so.3)
undefined symbol: krb5int_c_mandatory_cksumtype, version k5crypto_3_MIT	(/lib64/libkrb5.so.3)
undefined symbol: krb5_k_encrypt, version k5crypto_3_MIT	(/lib64/libkrb5.so.3)
undefined symbol: krb5_c_string_to_key, version k5crypto_3_MIT	(/lib64/libkrb5.so.3)
undefined symbol: krb5_c_block_size, version k5crypto_3_MIT	(/lib64/libkrb5.so.3)
undefined symbol: krb5int_c_mandatory_cksumtype, version k5crypto_3_MIT	(/lib64/libkrb5.so.3)
undefined symbol: krb5int_c_copy_keyblock_contents, version k5crypto_3_MIT	(/lib64/libkrb5.so.3)
undefined symbol: krb5_k_reference_key, version k5crypto_3_MIT	(/lib64/libkrb5.so.3)
undefined symbol: krb5int_c_combine_keys, version k5crypto_3_MIT	(/lib64/libkrb5.so.3)
undefined symbol: krb5_k_free_key, version k5crypto_3_MIT	(/lib64/libkrb5.so.3)
undefined symbol: krb5_c_enctype_compare, version k5crypto_3_MIT	(/lib64/libkrb5.so.3)
undefined symbol: krb5_string_to_enctype, version k5crypto_3_MIT	(/lib64/libkrb5.so.3)
undefined symbol: krb5_c_make_checksum, version k5crypto_3_MIT	(/lib64/libkrb5.so.3)
undefined symbol: krb5_k_decrypt, version k5crypto_3_MIT	(/lib64/libkrb5.so.3)
undefined symbol: krb5_c_fx_cf2_simple, version k5crypto_3_MIT	(/lib64/libkrb5.so.3)
undefined symbol: krb5_c_random_add_entropy, version k5crypto_3_MIT	(/lib64/libkrb5.so.3)
undefined symbol: krb5_k_create_key, version k5crypto_3_MIT	(/lib64/libkrb5.so.3)
undefined symbol: krb5int_c_init_keyblock, version k5crypto_3_MIT	(/lib64/libkrb5.so.3)
undefined symbol: krb5int_c_free_keyblock, version k5crypto_3_MIT	(/lib64/libkrb5.so.3)
undefined symbol: krb5int_c_weak_enctype, version k5crypto_3_MIT	(/lib64/libkrb5.so.3)
undefined symbol: krb5_c_checksum_length, version k5crypto_3_MIT	(/lib64/libkrb5.so.3)
undefined symbol: krb5_c_random_make_octets, version k5crypto_3_MIT	(/lib64/libkrb5.so.3)
undefined symbol: krb5_k_key_keyblock, version k5crypto_3_MIT	(/lib64/libkrb5.so.3)
undefined symbol: krb5_c_valid_cksumtype, version k5crypto_3_MIT	(/lib64/libkrb5.so.3)
undefined symbol: krb5_k_key_enctype, version k5crypto_3_MIT	(/lib64/libkrb5.so.3)
undefined symbol: krb5_c_encrypt_length, version k5crypto_3_MIT	(/lib64/libkrb5.so.3)
undefined symbol: krb5_c_string_to_key_with_params, version k5crypto_3_MIT	(/lib64/libkrb5.so.3)
undefined symbol: krb5int_c_copy_keyblock, version k5crypto_3_MIT	(/lib64/libkrb5.so.3)
undefined symbol: krb5_c_verify_checksum, version k5crypto_3_MIT	(/lib64/libkrb5.so.3)
undefined symbol: krb5_c_encrypt, version k5crypto_3_MIT	(/lib64/libkrb5.so.3)
undefined symbol: krb5_c_is_coll_proof_cksum, version k5crypto_3_MIT	(/lib64/libkrb5.so.3)
undefined symbol: krb5_enctype_to_string, version k5crypto_3_MIT	(/lib64/libkrb5.so.3)
undefined symbol: krb5_c_valid_enctype, version k5crypto_3_MIT	(/lib64/libkrb5.so.3)
undefined symbol: krb5_c_make_checksum_iov, version k5crypto_3_MIT	(/lib64/libkrb5.so.3)
undefined symbol: krb5_k_make_checksum, version k5crypto_3_MIT	(/lib64/libkrb5.so.3)
undefined symbol: krb5_k_verify_checksum, version k5crypto_3_MIT	(/lib64/libkrb5.so.3)
undefined symbol: krb5_c_is_keyed_cksum, version k5crypto_3_MIT	(/lib64/libkrb5.so.3)
undefined symbol: krb5_c_make_random_key, version k5crypto_3_MIT	(/lib64/libkrb5.so.3)
undefined symbol: krb5_enctype_to_name, version k5crypto_3_MIT	(/lib64/libkrb5.so.3)
undefined symbol: krb5_c_random_os_entropy, version k5crypto_3_MIT	(/lib64/libkrb5.so.3)
undefined symbol: krb5_c_keyed_checksum_types, version k5crypto_3_MIT	(/lib64/libkrb5.so.3)
undefined symbol: krb5int_c_free_keyblock_contents, version k5crypto_3_MIT	(/lib64/libkrb5.so.3)
undefined symbol: krb5_free_cksumtypes, version k5crypto_3_MIT	(/lib64/libkrb5.so.3)
undefined symbol: krb5_c_decrypt, version k5crypto_3_MIT	(/lib64/libkrb5.so.3)
undefined symbol: krb5_c_padding_length, version k5crypto_3_MIT	(/lib64/libgssapi_krb5.so.2)
undefined symbol: krb5_k_encrypt, version k5crypto_3_MIT	(/lib64/libgssapi_krb5.so.2)
undefined symbol: krb5_c_block_size, version k5crypto_3_MIT	(/lib64/libgssapi_krb5.so.2)
undefined symbol: krb5int_c_mandatory_cksumtype, version k5crypto_3_MIT	(/lib64/libgssapi_krb5.so.2)
undefined symbol: krb5_k_free_key, version k5crypto_3_MIT	(/lib64/libgssapi_krb5.so.2)
undefined symbol: krb5_c_make_checksum, version k5crypto_3_MIT	(/lib64/libgssapi_krb5.so.2)
undefined symbol: krb5_k_decrypt, version k5crypto_3_MIT	(/lib64/libgssapi_krb5.so.2)
undefined symbol: krb5_k_make_checksum_iov, version k5crypto_3_MIT	(/lib64/libgssapi_krb5.so.2)
undefined symbol: krb5_k_create_key, version k5crypto_3_MIT	(/lib64/libgssapi_krb5.so.2)
undefined symbol: krb5_c_checksum_length, version k5crypto_3_MIT	(/lib64/libgssapi_krb5.so.2)
undefined symbol: krb5_c_crypto_length, version k5crypto_3_MIT	(/lib64/libgssapi_krb5.so.2)
undefined symbol: krb5_c_random_make_octets, version k5crypto_3_MIT	(/lib64/libgssapi_krb5.so.2)
undefined symbol: krb5_k_key_keyblock, version k5crypto_3_MIT	(/lib64/libgssapi_krb5.so.2)
undefined symbol: krb5_k_key_enctype, version k5crypto_3_MIT	(/lib64/libgssapi_krb5.so.2)
undefined symbol: krb5_c_prf_length, version k5crypto_3_MIT	(/lib64/libgssapi_krb5.so.2)
undefined symbol: krb5int_arcfour_gsscrypt, version k5crypto_3_MIT	(/lib64/libgssapi_krb5.so.2)
undefined symbol: krb5_encrypt_size, version k5crypto_3_MIT	(/lib64/libgssapi_krb5.so.2)
undefined symbol: krb5_c_valid_enctype, version k5crypto_3_MIT	(/lib64/libgssapi_krb5.so.2)
undefined symbol: krb5_k_prf, version k5crypto_3_MIT	(/lib64/libgssapi_krb5.so.2)
undefined symbol: krb5_k_make_checksum, version k5crypto_3_MIT	(/lib64/libgssapi_krb5.so.2)
undefined symbol: krb5_k_verify_checksum, version k5crypto_3_MIT	(/lib64/libgssapi_krb5.so.2)
undefined symbol: krb5_k_verify_checksum_iov, version k5crypto_3_MIT	(/lib64/libgssapi_krb5.so.2)
undefined symbol: krb5_k_encrypt_iov, version k5crypto_3_MIT	(/lib64/libgssapi_krb5.so.2)
undefined symbol: krb5_k_decrypt_iov, version k5crypto_3_MIT	(/lib64/libgssapi_krb5.so.2)
undefined symbol: valid_cksumtype, version k5crypto_3_MIT	(/usr/lib64/libssl.so.10)
undefined symbol: krb5_checksum_size, version k5crypto_3_MIT	(/usr/lib64/libssl.so.10)$ ldd extest.so | wc -l
25$ ldd -d extest.so | wc -l
undefined symbol: krb5int_arcfour_gsscrypt, version k5crypto_3_MIT	(/lib64/libkrb5.so.3)
undefined symbol: krb5int_c_mandatory_cksumtype, version k5crypto_3_MIT	(/lib64/libkrb5.so.3)
25$ ldd -r extest.so | wc -l
undefined symbol: krb5int_arcfour_gsscrypt, version k5crypto_3_MIT	(/lib64/libkrb5.so.3)
undefined symbol: krb5int_c_mandatory_cksumtype, version k5crypto_3_MIT	(/lib64/libkrb5.so.3)
undefined symbol: krb5_k_encrypt, version k5crypto_3_MIT	(/lib64/libkrb5.so.3)
undefined symbol: krb5_c_string_to_key, version k5crypto_3_MIT	(/lib64/libkrb5.so.3)
undefined symbol: krb5_c_block_size, version k5crypto_3_MIT	(/lib64/libkrb5.so.3)
undefined symbol: krb5int_c_mandatory_cksumtype, version k5crypto_3_MIT	(/lib64/libkrb5.so.3)
undefined symbol: krb5int_c_copy_keyblock_contents, version k5crypto_3_MIT	(/lib64/libkrb5.so.3)
undefined symbol: krb5_k_reference_key, version k5crypto_3_MIT	(/lib64/libkrb5.so.3)
undefined symbol: krb5int_c_combine_keys, version k5crypto_3_MIT	(/lib64/libkrb5.so.3)
undefined symbol: krb5_k_free_key, version k5crypto_3_MIT	(/lib64/libkrb5.so.3)
undefined symbol: krb5_c_enctype_compare, version k5crypto_3_MIT	(/lib64/libkrb5.so.3)
undefined symbol: krb5_string_to_enctype, version k5crypto_3_MIT	(/lib64/libkrb5.so.3)
undefined symbol: krb5_c_make_checksum, version k5crypto_3_MIT	(/lib64/libkrb5.so.3)
undefined symbol: krb5_k_decrypt, version k5crypto_3_MIT	(/lib64/libkrb5.so.3)
undefined symbol: krb5_c_fx_cf2_simple, version k5crypto_3_MIT	(/lib64/libkrb5.so.3)
undefined symbol: krb5_c_random_add_entropy, version k5crypto_3_MIT	(/lib64/libkrb5.so.3)
undefined symbol: krb5_k_create_key, version k5crypto_3_MIT	(/lib64/libkrb5.so.3)
undefined symbol: krb5int_c_init_keyblock, version k5crypto_3_MIT	(/lib64/libkrb5.so.3)
undefined symbol: krb5int_c_free_keyblock, version k5crypto_3_MIT	(/lib64/libkrb5.so.3)
undefined symbol: krb5int_c_weak_enctype, version k5crypto_3_MIT	(/lib64/libkrb5.so.3)
undefined symbol: krb5_c_checksum_length, version k5crypto_3_MIT	(/lib64/libkrb5.so.3)
undefined symbol: krb5_c_random_make_octets, version k5crypto_3_MIT	(/lib64/libkrb5.so.3)
undefined symbol: krb5_k_key_keyblock, version k5crypto_3_MIT	(/lib64/libkrb5.so.3)
undefined symbol: krb5_c_valid_cksumtype, version k5crypto_3_MIT	(/lib64/libkrb5.so.3)
undefined symbol: krb5_k_key_enctype, version k5crypto_3_MIT	(/lib64/libkrb5.so.3)
undefined symbol: krb5_c_encrypt_length, version k5crypto_3_MIT	(/lib64/libkrb5.so.3)
undefined symbol: krb5_c_string_to_key_with_params, version k5crypto_3_MIT	(/lib64/libkrb5.so.3)
undefined symbol: krb5int_c_copy_keyblock, version k5crypto_3_MIT	(/lib64/libkrb5.so.3)
undefined symbol: krb5_c_verify_checksum, version k5crypto_3_MIT	(/lib64/libkrb5.so.3)
undefined symbol: krb5_c_encrypt, version k5crypto_3_MIT	(/lib64/libkrb5.so.3)
undefined symbol: krb5_c_is_coll_proof_cksum, version k5crypto_3_MIT	(/lib64/libkrb5.so.3)
undefined symbol: krb5_enctype_to_string, version k5crypto_3_MIT	(/lib64/libkrb5.so.3)
undefined symbol: krb5_c_valid_enctype, version k5crypto_3_MIT	(/lib64/libkrb5.so.3)
undefined symbol: krb5_c_make_checksum_iov, version k5crypto_3_MIT	(/lib64/libkrb5.so.3)
undefined symbol: krb5_k_make_checksum, version k5crypto_3_MIT	(/lib64/libkrb5.so.3)
undefined symbol: krb5_k_verify_checksum, version k5crypto_3_MIT	(/lib64/libkrb5.so.3)
undefined symbol: krb5_c_is_keyed_cksum, version k5crypto_3_MIT	(/lib64/libkrb5.so.3)
undefined symbol: krb5_c_make_random_key, version k5crypto_3_MIT	(/lib64/libkrb5.so.3)
undefined symbol: krb5_enctype_to_name, version k5crypto_3_MIT	(/lib64/libkrb5.so.3)
undefined symbol: krb5_c_random_os_entropy, version k5crypto_3_MIT	(/lib64/libkrb5.so.3)
undefined symbol: krb5_c_keyed_checksum_types, version k5crypto_3_MIT	(/lib64/libkrb5.so.3)
undefined symbol: krb5int_c_free_keyblock_contents, version k5crypto_3_MIT	(/lib64/libkrb5.so.3)
undefined symbol: krb5_free_cksumtypes, version k5crypto_3_MIT	(/lib64/libkrb5.so.3)
undefined symbol: krb5_c_decrypt, version k5crypto_3_MIT	(/lib64/libkrb5.so.3)
undefined symbol: krb5_c_padding_length, version k5crypto_3_MIT	(/lib64/libgssapi_krb5.so.2)
undefined symbol: krb5_k_encrypt, version k5crypto_3_MIT	(/lib64/libgssapi_krb5.so.2)
undefined symbol: krb5_c_block_size, version k5crypto_3_MIT	(/lib64/libgssapi_krb5.so.2)
undefined symbol: krb5int_c_mandatory_cksumtype, version k5crypto_3_MIT	(/lib64/libgssapi_krb5.so.2)
undefined symbol: krb5_k_free_key, version k5crypto_3_MIT	(/lib64/libgssapi_krb5.so.2)
undefined symbol: krb5_c_make_checksum, version k5crypto_3_MIT	(/lib64/libgssapi_krb5.so.2)
undefined symbol: krb5_k_decrypt, version k5crypto_3_MIT	(/lib64/libgssapi_krb5.so.2)
undefined symbol: krb5_k_make_checksum_iov, version k5crypto_3_MIT	(/lib64/libgssapi_krb5.so.2)
undefined symbol: krb5_k_create_key, version k5crypto_3_MIT	(/lib64/libgssapi_krb5.so.2)
undefined symbol: krb5_c_checksum_length, version k5crypto_3_MIT	(/lib64/libgssapi_krb5.so.2)
undefined symbol: krb5_c_crypto_length, version k5crypto_3_MIT	(/lib64/libgssapi_krb5.so.2)
undefined symbol: krb5_c_random_make_octets, version k5crypto_3_MIT	(/lib64/libgssapi_krb5.so.2)
undefined symbol: krb5_k_key_keyblock, version k5crypto_3_MIT	(/lib64/libgssapi_krb5.so.2)
undefined symbol: krb5_k_key_enctype, version k5crypto_3_MIT	(/lib64/libgssapi_krb5.so.2)
undefined symbol: krb5_c_prf_length, version k5crypto_3_MIT	(/lib64/libgssapi_krb5.so.2)
undefined symbol: krb5int_arcfour_gsscrypt, version k5crypto_3_MIT	(/lib64/libgssapi_krb5.so.2)
undefined symbol: krb5_encrypt_size, version k5crypto_3_MIT	(/lib64/libgssapi_krb5.so.2)
undefined symbol: krb5_c_valid_enctype, version k5crypto_3_MIT	(/lib64/libgssapi_krb5.so.2)
undefined symbol: krb5_k_prf, version k5crypto_3_MIT	(/lib64/libgssapi_krb5.so.2)
undefined symbol: krb5_k_make_checksum, version k5crypto_3_MIT	(/lib64/libgssapi_krb5.so.2)
undefined symbol: krb5_k_verify_checksum, version k5crypto_3_MIT	(/lib64/libgssapi_krb5.so.2)
undefined symbol: krb5_k_verify_checksum_iov, version k5crypto_3_MIT	(/lib64/libgssapi_krb5.so.2)
undefined symbol: krb5_k_encrypt_iov, version k5crypto_3_MIT	(/lib64/libgssapi_krb5.so.2)
undefined symbol: krb5_k_decrypt_iov, version k5crypto_3_MIT	(/lib64/libgssapi_krb5.so.2)
undefined symbol: valid_cksumtype, version k5crypto_3_MIT	(/usr/lib64/libssl.so.10)
undefined symbol: krb5_checksum_size, version k5crypto_3_MIT	(/usr/lib64/libssl.so.10)
25

ldd可用于查看ELF格式动态可执行文件的依赖关系,如:动态库、可执行程。不能查看其它文件,如:静态库。

$ file test.a 
test.a: current ar archive$ file extest.so 
extest.so: ELF 64-bit LSB shared object, x86-64, version 1 (SYSV), dynamically linked, not stripped$ file recv
recv: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.18, not stripped$ ldd test.a 不是动态可执行文件$ ldd extest.so linux-vdso.so.1 =>  (0x00007fff89fff000)libdl.so.2 => /lib64/libdl.so.2 (0x00007fa3485d0000)libssl.so.10 => /usr/lib64/libssl.so.10 (0x00007fa348375000)libpthread.so.0 => /lib64/libpthread.so.0 (0x00007fa348158000)libstdc++.so.6 => /usr/lib64/libstdc++.so.6 (0x00007fa347e51000)libm.so.6 => /lib64/libm.so.6 (0x00007fa347abb000)libgcc_s.so.1 => /lib64/libgcc_s.so.1 (0x00007fa3478a4000)libc.so.6 => /lib64/libc.so.6 (0x00007fa347511000)/lib64/ld-linux-x86-64.so.2 (0x0000003421c00000)libgssapi_krb5.so.2 => /lib64/libgssapi_krb5.so.2 (0x00007fa3472cd000)libkrb5.so.3 => /lib64/libkrb5.so.3 (0x00007fa346fe6000)libcom_err.so.2 => /lib64/libcom_err.so.2 (0x00007fa346de2000)libk5crypto.so.3 => /lib64/libk5crypto.so.3 (0x00007fa346bb6000)libcrypto.so.10 => /usr/lib64/libcrypto.so.10 (0x00007fa34681b000)libz.so.1 => /lib64/libz.so.1 (0x00007fa346605000)libnsl.so.1 => /lib64/libnsl.so.1 (0x00007fa3463ec000)librt.so.1 => /lib64/librt.so.1 (0x00007fa3461e3000)libkrb5support.so.0 => /lib64/libkrb5support.so.0 (0x00007fa345fd8000)libkeyutils.so.1 => /lib64/libkeyutils.so.1 (0x00007fa345dd5000)libresolv.so.2 => /lib64/libresolv.so.2 (0x00007fa345bba000)libselinux.so.1 => /lib64/libselinux.so.1 (0x00007fa34599b000)$ ll recv*
-rw-rw-r--. 1 tangf tangf 2949 2月  26 2019 recv.cpp
-rwxrwxr-x. 1 tangf tangf 9630 2月  26 2019 recv$ ldd recv.cpp 
ldd: 警告: 你没有执行权限  `./recv.cpp'不是动态可执行文件$ ldd recvlinux-vdso.so.1 =>  (0x00007fff07dff000)libstdc++.so.6 => /usr/lib64/libstdc++.so.6 (0x0000003429000000)libm.so.6 => /lib64/libm.so.6 (0x0000003423000000)libgcc_s.so.1 => /lib64/libgcc_s.so.1 (0x0000003427400000)libc.so.6 => /lib64/libc.so.6 (0x0000003422400000)/lib64/ld-linux-x86-64.so.2 (0x0000003421c00000)

如果依赖的某个库找不到,通过这个命令可以迅速定位问题所在。

# ll /lib64/libk5crypto.so.3
lrwxrwxrwx. 1 root root 18 Aug  8  2018 /lib64/libk5crypto.so.3 -> libk5crypto.so.3.1# mv /lib64/libk5crypto.so.3 /lib64/libk5crypto.so.4# ll /lib64/libk5crypto.so.3
ls: cannot access /lib64/libk5crypto.so.3: No such file or directory$ ldd extest.so | grep --color=auto libk5crypto.so.3libk5crypto.so.3 => not foundlibk5crypto.so.3 => not foundlibk5crypto.so.3 => not found$ ldd extest.so | grep --color=auto "not found"libk5crypto.so.3 => not foundlibk5crypto.so.3 => not foundlibk5crypto.so.3 => not found# mv /lib64/libk5crypto.so.4 /lib64/libk5crypto.so.3
# ll /lib64/libk5crypto.so.3
lrwxrwxrwx. 1 root root 18 Aug  8  2018 /lib64/libk5crypto.so.3 -> libk5crypto.so.3.1$ ldd extest.so | grep --color=auto libk5crypto.so.3libk5crypto.so.3 => /lib64/libk5crypto.so.3 (0x00007f28c90d0000)$  ldd extest.so | grep --color=auto "not found" | wc -l
0

这篇关于Linux系统实用工具——ldd的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!



http://www.chinasem.cn/article/850181

相关文章

Linux磁盘分区、格式化和挂载方式

《Linux磁盘分区、格式化和挂载方式》本文详细介绍了Linux系统中磁盘分区、格式化和挂载的基本操作步骤和命令,包括MBR和GPT分区表的区别、fdisk和gdisk命令的使用、常见的文件系统格式以... 目录一、磁盘分区表分类二、fdisk命令创建分区1、交互式的命令2、分区主分区3、创建扩展分区,然后

Linux中chmod权限设置方式

《Linux中chmod权限设置方式》本文介绍了Linux系统中文件和目录权限的设置方法,包括chmod、chown和chgrp命令的使用,以及权限模式和符号模式的详细说明,通过这些命令,用户可以灵活... 目录设置基本权限命令:chmod1、权限介绍2、chmod命令常见用法和示例3、文件权限详解4、ch

Linux内核之内核裁剪详解

《Linux内核之内核裁剪详解》Linux内核裁剪是通过移除不必要的功能和模块,调整配置参数来优化内核,以满足特定需求,裁剪的方法包括使用配置选项、模块化设计和优化配置参数,图形裁剪工具如makeme... 目录简介一、 裁剪的原因二、裁剪的方法三、图形裁剪工具四、操作说明五、make menuconfig

Linux使用nohup命令在后台运行脚本

《Linux使用nohup命令在后台运行脚本》在Linux或类Unix系统中,后台运行脚本是一项非常实用的技能,尤其适用于需要长时间运行的任务或服务,本文我们来看看如何使用nohup命令在后台... 目录nohup 命令简介基本用法输出重定向& 符号的作用后台进程的特点注意事项实际应用场景长时间运行的任务服

什么是cron? Linux系统下Cron定时任务使用指南

《什么是cron?Linux系统下Cron定时任务使用指南》在日常的Linux系统管理和维护中,定时执行任务是非常常见的需求,你可能需要每天执行备份任务、清理系统日志或运行特定的脚本,而不想每天... 在管理 linux 服务器的过程中,总有一些任务需要我们定期或重复执行。就比如备份任务,通常会选在服务器资

TP-LINK/水星和hasivo交换机怎么选? 三款网管交换机系统功能对比

《TP-LINK/水星和hasivo交换机怎么选?三款网管交换机系统功能对比》今天选了三款都是”8+1″的2.5G网管交换机,分别是TP-LINK水星和hasivo交换机,该怎么选呢?这些交换机功... TP-LINK、水星和hasivo这三台交换机都是”8+1″的2.5G网管交换机,我手里的China编程has

Linux限制ip访问的解决方案

《Linux限制ip访问的解决方案》为了修复安全扫描中发现的漏洞,我们需要对某些服务设置访问限制,具体来说,就是要确保只有指定的内部IP地址能够访问这些服务,所以本文给大家介绍了Linux限制ip访问... 目录背景:解决方案:使用Firewalld防火墙规则验证方法深度了解防火墙逻辑应用场景与扩展背景:

Linux下MySQL8.0.26安装教程

《Linux下MySQL8.0.26安装教程》文章详细介绍了如何在Linux系统上安装和配置MySQL,包括下载、解压、安装依赖、启动服务、获取默认密码、设置密码、支持远程登录以及创建表,感兴趣的朋友... 目录1.找到官网下载位置1.访问mysql存档2.下载社区版3.百度网盘中2.linux安装配置1.

Linux使用粘滞位 (t-bit)共享文件的方法教程

《Linux使用粘滞位(t-bit)共享文件的方法教程》在Linux系统中,共享文件是日常管理和协作中的常见任务,而粘滞位(StickyBit或t-bit)是实现共享目录安全性的重要工具之一,本文将... 目录文件共享的常见场景基础概念linux 文件权限粘滞位 (Sticky Bit)设置共享目录并配置粘

基于Qt实现系统主题感知功能

《基于Qt实现系统主题感知功能》在现代桌面应用程序开发中,系统主题感知是一项重要的功能,它使得应用程序能够根据用户的系统主题设置(如深色模式或浅色模式)自动调整其外观,Qt作为一个跨平台的C++图形用... 目录【正文开始】一、使用效果二、系统主题感知助手类(SystemThemeHelper)三、实现细节