通过LD_DEUBG=libs解决动态库缺失

前言

很多情况下编译完成或者安装完成的程序运行时都会遇到难以避免的问题:“error while loading shared libraries: libevent-2.1.so.7: cannot open shared object file: No such file or directory” ,新手往往难以定位程序在加载时到底在哪个位置寻找了这些动态库。

以Transmission所需的其中一个库libevent-2.1.so.7为例。

定位所需库文件的路径

find / - name libevent-2.1.so.7 2>/dev/null

    /usr/local/x86_64-gnu-linux/libevent-2.1.so.7

使用DEUBG模式回显程序加载内容

LD_DEUBG=libs transmission-daemon 

    ......
      2186:   trying file=/lib/tls/x86_64/libevent-2.1.so.7
      2186:   trying file=/lib/tls/x86_64/libevent-2.1.so.7
      2186:   trying file=/lib/tls/libevent-2.1.so.7
      2186:   trying file=/lib/x86_64/x86_64/libevent-2.1.so.7
      2186:   trying file=/lib/x86_64/libevent-2.1.so.7
      2186:   trying file=/lib/x86_64/libevent-2.1.so.7
      2186:   trying file=/lib/libevent-2.1.so.7
      2186:   trying file=/usr/lib/tls/x86_64/x86_64/libevent-2.1.so.7
      2186:   trying file=/usr/lib/tls/x86_64/libevent-2.1.so.7
      2186:   trying file=/usr/lib/tls/x86_64/libevent-2.1.so.7
      2186:   trying file=/usr/lib/tls/libevent-2.1.so.7
      2186:   trying file=/usr/lib/x86_64/x86_64/libevent-2.1.so.7
      2186:   trying file=/usr/lib/x86_64/libevent-2.1.so.7
      2186:   trying file=/usr/lib/x86_64/libevent-2.1.so.7
      2186:   trying file=/usr/lib/libevent-2.1.so.7
      2186:
    /opt/transmission/bin/transmission-daemon: error while loading shared libraries: libevent-2.1.so.7: cannot open shared object file: No such file or directory

为动态库创建软连接

sudo ln -s /usr/lib/x86_64-linux-gnu/libevent-2.1.so.6 /usr/lib/libevent-2.1.so.7

重新运行程序,无报错。

zhijun1997

我还没有学会写个人说明!

暂无评论

相关推荐

Linux 软件源

Ubuntu/Debian 源 备份软件源(当然,你也可以选择不备份) sudo cp /etc/apt/sources.list /etc/apt/sources.list_bak ...

微信扫一扫,分享到朋友圈

通过LD_DEUBG=libs解决动态库缺失