LD_DEBUG=xxx

使用ldd命令可以知道程序依赖于哪些库,在找不到这些库的时候,使用LD_DEBUG可以知道系统在哪些路径下进行了尝试。
  例如:
root@ubuntu:/usr/local/bin# ldd memcached
linux-vdso.so.1 =>  (0x00007ffff4ffc000)
libevent-1.4.so.2 => not found
libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 (0x00007f3b0579c000)
libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f3b053d6000)
/lib64/ld-linux-x86-64.so.2 (0x00007f3b059c2000)

使用LD_DEBUG查看:
root@ubuntu:/usr/local/lib# LD_DEBUG=libs /usr/local/bin/memcached -v 
     12842: find library=libevent-1.4.so.2 [0]; searching
     12842: search cache=/etc/ld.so.cache
     12842: search path=/lib/x86_64-linux-gnu/tls/x86_64:/lib/x86_64-linux-gnu/tls:/lib/x86_64-linux-gnu/x86_64:/lib/x86_64-linux-gnu:/usr/lib/x86_64-linux-gnu/tls/x86_64:/usr/lib/x86_64-linux-gnu/tls:/usr/lib/x86_64-linux-gnu/x86_64:/usr/lib/x86_64-linux-gnu:/lib/tls/x86_64:/lib/tls:/lib/x86_64:/lib:/usr/lib/tls/x86_64:/usr/lib/tls:/usr/lib/x86_64:/usr/lib(system search path)
     12842:  trying file=/lib/x86_64-linux-gnu/tls/x86_64/libevent-1.4.so.2
     12842:  trying file=/lib/x86_64-linux-gnu/tls/libevent-1.4.so.2
     12842:  trying file=/lib/x86_64-linux-gnu/x86_64/libevent-1.4.so.2
     12842:  trying file=/lib/x86_64-linux-gnu/libevent-1.4.so.2
     12842:  trying file=/usr/lib/x86_64-linux-gnu/tls/x86_64/libevent-1.4.so.2
     12842:  trying file=/usr/lib/x86_64-linux-gnu/tls/libevent-1.4.so.2
     12842:  trying file=/usr/lib/x86_64-linux-gnu/x86_64/libevent-1.4.so.2
     12842:  trying file=/usr/lib/x86_64-linux-gnu/libevent-1.4.so.2
     12842:  trying file=/lib/tls/x86_64/libevent-1.4.so.2
     12842:  trying file=/lib/tls/libevent-1.4.so.2
     12842:  trying file=/lib/x86_64/libevent-1.4.so.2
     12842:  trying file=/lib/libevent-1.4.so.2
     12842:  trying file=/usr/lib/tls/x86_64/libevent-1.4.so.2
     12842:  trying file=/usr/lib/tls/libevent-1.4.so.2
     12842:  trying file=/usr/lib/x86_64/libevent-1.4.so.2
     12842:  trying file=/usr/lib/libevent-1.4.so.2
     12842:
/usr/local/bin/memcached: error while loading shared libraries: libevent-1.4.so.2: cannot open shared object file: No such file or directory

查看LD_DEBUG帮助:  LD_DEBUG=help ./memcached

root@ubuntu:/usr/local/lib# LD_DEBUG=help /usr/local/bin/memcached
Valid options for the LD_DEBUG environment variable are:


  libs        display library search paths
  reloc       display relocation processing
  files       display progress for input file
  symbols     display symbol table processing
  bindings    display information about symbol binding
  versions    display version dependencies
  scopes      display scope information
  all         all previous options combined
  statistics  display relocation statistics
  unused      determined unused DSOs
  help        display this help message and exit


To direct the debugging output into a file instead of standard output
a filename can be specified using the LD_DEBUG_OUTPUT environment variable.


果想将结果放到一个文件里:LD_DEBUG=libs  LD_DEBUG_OUTPUT=log ./usr/local/bin/memcached
就会产生一个log.XXXX的文件:
[gliang1@localhost Linux2.6_64]$ ls
log.15051
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值