引用
LD_DEBUG
The dynamic library loader used in linux
(part of glibc) has some neat tricks. One of these is that you can set an
environment variable called
LD_DEBUG

to show how symbols (variables
and functions, for example) are resolved for a dynamic executable. This can
sometimes help resolve obscure bugs where your application isn’t doing what you
expect (assuming it is caused by symbols being resolved differently to what you
were expecting).

This is very useful if you get segmentation violations
or aborts for a program - this can sometimes be caused by linking against the
wrong version of a library. This is also a really good way to understand what
happens when you run any program! It has some self-documentation - for the
impatient, you can
do

原文引述一下memcached的问题:

LD_DEBUG 是 glibc
中的 loader 为了方便自身调试而设置的一个环境变量。通过设置这个环境变量,可以方便的看到 loader 的加载过程。 以在 64位 centos
上编译安装 memcached 为例,安装阶段顺利,执行 memcached 命令时出现错误:

#memcached –h
/usr/local/memcached/bin/memcached: error while
loading shared libraries: libevent-1.4.so.2:
cannot open shared object file:
No such file or directory
#find / -name
libevent-1.4.so.2
/usr/lib/libevent-1.4.so.2

设置 LD_DEBUG
变量获得更多信息:

#LD_DEBUG=help ls
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
  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.

库依赖的问题,使用 libs 参数:

#LD_DEBUG=libs /usr/local/memcached/bin/memcached
–h
9808:      find library=libevent-1.4.so.2 [0];
searching
9808:      search cache=/etc/ld.so.cache
9808:      search
path=/lib64/tls/x86_64:/lib64/tls:/lib64/x86_64:/lib64:/usr/lib64/tls/x86_64
/usr/lib64/tls:/usr/lib64/x86_64:/usr/lib64
(system
search path)
9808:      trying
file=/lib64/tls/x86_64/libevent-1.4.so.2
9808:      trying
file=/lib64/tls/libevent-1.4.so.2
9808:      trying
file=/lib64/x86_64/libevent-1.4.so.2
9808:      trying
file=/lib64/libevent-1.4.so.2
9808:      trying
file=/usr/lib64/tls/x86_64/libevent-1.4.so.2
9808:      trying
file=/usr/lib64/tls/libevent-1.4.so.2
9808:      trying
file=/usr/lib64/x86_64/libevent-1.4.so.2
9808:      trying
file=/usr/lib64/libevent-1.4.so.2
9808:      /usr/local/memcached/bin/memcached:
error while loading shared libraries: libevent-1.4.so.2: cannot open shared
object file: No such file or directory

问题一目了然:

ln -s /usr/lib/libevent-1.4.so.2 /usr/lib64/libevent-1.4.so.2

参考原文:
http://grepk.com/?p=62
http://blog.chinaunix.net/u1/59481/showart_2131371.html

关于LD_DEBUG (转载)的更多相关文章

  1. Crystal Clear Applied: The Seven Properties of Running an Agile Project (转载)

    作者Alistair Cockburn, Crystal Clear的7个成功要素,写得挺好. 敏捷方法的关注点,大家可以参考,太激动所以转载了. 原文:http://www.informit.com ...

  2. RTP与RTCP协议介绍(转载)

    RTSP发起/终结流媒体.RTP传输流媒体数据 .RTCP对RTP进行控制,同步.RTP中没有连接的概念,本身并不能为按序传输数据包提供可靠的保证,也不提供流量控制和拥塞控制,这些都由RTCP来负责完 ...

  3. 《Walking the callstack(转载)》

    本文转载自:https://www.codeproject.com/articles/11132/walking-the-callstack Download demo project with so ...

  4. [转载]MVVM模式原理分析及实践

    没有找到很好的MVVM模式介绍文章,简单找了一篇,分享一下.MVVM实现了UI\UE设计师(Expression Blend 4设计界面)和软件工程师的合理分工,在SilverLight.WPF.Wi ...

  5. [转载]:STM32为什么必须先配置时钟再配置GPIO

    转载来源 :http://blog.csdn.net/fushiqianxun/article/details/7926442 [原创]:我来添两句,就是很多同学(包括我)之前搞低端单片机,到了stm ...

  6. [转载]从MyEclipse到IntelliJ IDEA-让你摆脱鼠标,全键盘操作

    从MyEclipse转战到IntelliJ IDEA的经历 注转载址:http://blog.csdn.net/luoweifu/article/details/13985835 我一个朋友写了一篇“ ...

  7. TCP同步与异步,长连接与短连接【转载】

    原文地址:TCP同步与异步,长连接与短连接作者:1984346023 [转载说明:http://zjj1211.blog.51cto.com/1812544/373896   这是今天看到的一篇讲到T ...

  8. 在CentOS 7/6.5/6.4 中安装Java JDK 8(转载)

    转载在CentOS 7/6.5/6.4 中安装Java JDK 8 首先,在你的服务器上运行一下更新. yum update 然后,在您的系统上搜索,任何版本的已安装的JDK组件. rpm -qa | ...

  9. 用C#实现MD5的加密(转载)

    方法一 首先,先简单介绍一下MD5 MD5的全称是message-digest algorithm 5(信息-摘要算法,在90年代初由mit laboratory for computer scien ...

随机推荐

  1. Linux前台的程序转到后台执行(关闭终端而不杀死命令)

    你是否经常遇到这样的情况,通过SSH或者终端putty连接到一台linux/unix机器,执行一个程序.一个脚本或者一条命令,但现在你需要关闭SSH或者终端,由于该该程序.脚本或者命令正在运行,一旦你 ...

  2. Deep Learning(深度学习)学习笔记整理系列之(四)

    Deep Learning(深度学习)学习笔记整理系列 zouxy09@qq.com http://blog.csdn.net/zouxy09 作者:Zouxy version 1.0 2013-04 ...

  3. 在 Visio 中录制宏

    在“开发工具”选项卡上,单击“录制宏”.(如果您看不到“开发工具”选项卡,请参阅下面的“显示‘开发工具’选项卡”.) 在“宏名”框中,键入宏名称. 在“快捷键”框中,键入与 Ctrl 键一起使用可运行 ...

  4. js substr()与substring()的区别

    定义和用法 substr 方法用于返回一个从指定位置开始的指定长度的子字符串. 语法 stringObject.substr(start [, length ]) 参数 描述 start 必需.所需的 ...

  5. Oracle 客户端配置笔记

    1.右击桌面的我的电脑 -> 高级 -> 环境变量,新建 1) 变量名:ORACLE_HOME 变量值:D:\app\instantclient_11_2 2) 变量名:TNS_ADMIN ...

  6. 转 --maven系列之一 简介

    http://blog.csdn.net/jiuqiyuliang/article/details/41076215 [项目管理和构建]——Maven简介(一) 2015-01-31 21:27 68 ...

  7. 笔记-linux下Qt5.3.2 静态编译

    这里主要讲linux下的编译,windows下面比较简单 参考:http://qt-project.org/wiki/Building-Qt-5-from-Git 依赖 sudo apt-get in ...

  8. Python学习笔记 (1) :python简介、工具、编码及基础运算

    学习背景: 精通一门编程语言并编写出自己喜欢的程序是我多年的梦想,一定要找时间实现.此时想起了高中时的我对编程的兴趣十分浓厚,父母给自己购买了学习机插卡式的,只能敲basic代码,同时学校有386计算 ...

  9. 求模和求余(附加C语言实现)

    求模和求余的总体计算步骤如下: 1.求整数商  c = a/b 2.计算模或者余数 r = a - c*b 求模和求余的第一步不同,求余在取c的值时向0方向舍入;取模在计算c的值时向无穷小方向舍入. ...

  10. Bluetooth 2.1+EDR是什么

    目前应用最为广泛的是 Bluetooth 2.0+EDR标准,该标准在2004年已经推出,支持Bluetooth 2.0+EDR标准的产品也于2006年大量出现.虽然Bluetooth 2.0+EDR ...