关于dynamic library存在却找不到的解决方法

有朋友问在linux中动态链接库.so文件在机器上却无法load,以mplayer为例,编译时正常。但运行时却出现如下问题:


./mplayer
./mplayer: error while loading shared libraries: libva-x11.so.1:
cannot open shared object file: No such file or directory


ldd ./mplayer

libva-x11.so.1 => not found
libva-glx.so.1 => not found
libfaac.so.0 => /usr/lib/libfaac.so.0 (0x0014f000)
libva.so.1 => not found


上面那三个not found的文件都在/usr/local/lib中,可以用下面的方法解决:


  1. LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/lib ./myplayer
  2. 编辑/etc/ld.so.conf, 在其中添加/usr/local/lib,然后 ldconfig

对于第二种方法要记得把/usr/local/lib添加到最前面。




http://blog.microsuncn.com/?p=585

arrow
arrow
    全站熱搜

    立你斯 發表在 痞客邦 留言(0) 人氣()