chrpath工具使用

转载:http://www.cnblogs.com/kungfupanda/p/3708799.html

 

chrpath是用来改变程序的depends lib 的搜索路径的,比如我们一般使用
$ldd  application
    linux-vdso.so.1 =>  (0x00007fff89844000)
    libQt3Support.so.4 => /usr/lib/libQt3Support.so.4 (0x00007f53f7424000)
    libQtSql.so.4 => /usr/lib/libQtSql.so.4 (0x00007f53f71e6000)
    libQtXml.so.4 => /usr/lib/libQtXml.so.4 (0x00007f53f6f9f000)
    libQtNetwork.so.4 => /usr/lib/libQtNetwork.so.4 (0x00007f53f6c84000)
    libQtGui.so.4 => /usr/lib/libQtGui.so.4 (0x00007f53f60d0000)
    libQtCore.so.4 => /usr/lib/libQtCore.so.4 (0x00007f53f5c99000)
    libpthread.so.0 => /lib/libpthread.so.0 (0x00007f53f5a7d000)
    libstdc++.so.6 => /usr/lib/libstdc++.so.6 (0x00007f53f576d000)
    libm.so.6 => /lib/libm.so.6 (0x00007f53f54e9000)
    libgcc_s.so.1 => /lib/libgcc_s.so.1 (0x00007f53f52d2000)
那么我们现在想改变一个so库的搜索路径,不使用/usr/lib/下面的,而是用/usr/local/lib目录下面的,那么就可以使用chrpath工具了

$chrpath -r "/usr/local/lib/" application
application: RUNPATH=/usr/lib
application: new RUNPATH: /usr/local/lib

$chrpath -c application
application: RUNPATH=/usr/local/lib

$ldd application
    linux-vdso.so.1 =>  (0x00007fff76555000)
    libQt3Support.so.4 => /usr/local/lib/libQt3Support.so.4 (0x00007ff62e8a8000)
    libQtSql.so.4 => /usr/local/lib/libQtSql.so.4 (0x00007ff62e666000)
    libQtXml.so.4 => /usr/local/lib/libQtXml.so.4 (0x00007ff62e41d000)
    libQtNetwork.so.4 => /usr/local/lib/libQtNetwork.so.4 (0x00007ff62e0f0000)
    libQtGui.so.4 => /usr/local/lib/libQtGui.so.4 (0x00007ff62d436000)
    libQtCore.so.4 => /usr/local/lib/libQtCore.so.4 (0x00007ff62cfa6000)

That which didn't kill me makes me stronger
posted @ 2014-05-06 13:37  dolinux  阅读(766)  评论(0编辑  收藏  举报