Search code examples
linuxoperator-precedencedynamic-library

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 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!


Solution

  • 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!