开发者

LD_LIBRARY_PATH precedence

I've just stumbled on some weird behavior: before I launch my application I've set the LD_LIBRARY_PATH to some local lib directory which contains all needed libs. After launch I have part(the开发者_如何学Go most part) libs are loaded from the LD_LIBRARY_PATH but a few are loaded from the standard /usr/lib(e.g /usr/lib/libQtNetwork.so.4, /usr/lib/libSM.so.6). All those libs are contained in the directory which is listed in the LD_LIBRARY_PATH. Could anyone explain why do I have such behavior? I'm not very familiar with a Linux world but this article says that my approach should work

P.S. If I rename /usr/libs to something other I'll have my application running with all libs used from my libs location

Thank in advance!


I've found the answer and the answer is RPATH. All Qt libraries are built with RPATH=$QT_INSTALL_DIR so the RPATH should be removed if you want to create "bundle" in Linux. RPATH can be removed by invoking chrpath command. Thanks all for help!


Ok, seems you are using Qt, but the same principles applies and is not Qt specific.

The first thing to look at is your PATH environment variable, then QTDIR, then LD_LIBRARY_PATH.

Normally you do not need to "play" with LD_LIBRARY_PATH. If your PATH is correct then you should be fine.

As a side note (you probably know): To see the libraries used you can use the the ldd command. For example:

user@host:~/$ ldd $QTDIR/bin/qmake 
linux-vdso.so.1 =>  (0x00007fff169ff000)
libstdc++.so.6 => /usr/lib/libstdc++.so.6 (0x00007fb6bf63e000)
libm.so.6 => /lib/libm.so.6 (0x00007fb6bf3bb000)
libgcc_s.so.1 => /lib/libgcc_s.so.1 (0x00007fb6bf1a3000)
libc.so.6 => /lib/libc.so.6 (0x00007fb6bee20000)
/lib64/ld-linux-x86-64.so.2 (0x00007fb6bf97e000)

Assuming your QTDIR env variable is set. If you have QT if the linux distribution installed qmake will be in the path. If you did a custom install or compile you would need to set your path.

Good luck.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜