LD_LIBRARY_PATH priority

I just stumbled upon some strange behavior: before starting my application, I installed LD_LIBRARY_PATH in some local lib directory that contains all the necessary libraries. After starting up, I have part (most of) libs loaded from LD_LIBRARY_PATH, but some of them are loaded from the standard / usr / lib (for example, / usr / lib / libQtNetwork.so.4, / usr / lib / libSM.so. 6). All of these libraries are contained in the directory specified in LD_LIBRARY_PATH. Can someone explain why I have this behavior? I'm not very familiar with the Linux world, but in this article says my approach should work

PS If I rename / usr / libs to something else, I will have my application working with all the libs used in my libs directory

Thanks in advance!

+4
source share
2 answers

I found the answer and RPATH answer. All Qt libraries are built using RPATH = $ QT_INSTALL_DIR, so RPATH should be removed if you want to create a “package” on Linux. RPATH can be removed by calling chrpath . Thank you all for your help!

+2
source

Well, it looks like you are using Qt, but the same principles apply and are not specific to Qt.

The first thing you need to pay attention to is the PATH environment variable, then QTDIR, then LD_LIBRARY_PATH .

Usually you do not need to “play” with LD_LIBRARY_PATH. If your PATH is correct, you should be fine.

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

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) 

Suppose your enver QTDIR variable is set. If you have QT, if the linux distribution is installed qmake will be in the way. If you have done a custom installation or compilation, you will need to specify your path.

Good luck.

0
source

Source: https://habr.com/ru/post/1344447/


All Articles