user2346536
user2346536

Reputation: 1474

ldd finds a libQtCore magically

when I LDD my program, i get this line among others

libQtCore.so.4 => /Soft/fox_dev/Qt-4.7.4/lib/libQtCore.so.4

however this path is neither in my PATH nor in my LD_LIBRARY_PATH and executing:

set | grep -i qt

I find that the "bin" repository only is in my path

/Soft/fox_dev/Qt-4.7.4/bin/

But there is no any environment variable set to the path of the QtCore libraries.

Question: how does the "ldd" command find this path ? ( the program also executes fine )

Upvotes: 0

Views: 106

Answers (1)

DNT
DNT

Reputation: 2395

ldd actually executes your program using load tracing. The loader (ld.so or ld-linux.so) uses a cache created by running ldconfig after one or more .so files are installed in a directory. You can find the relevant information here. There are a few methods to override this if you want to use a different Qt installation. The easiest one, is to set

export LD_LIBRARY_PATH=<my Qt libs location>:$LD_LIBRARY_PATH

in a script and then run a shell like

bash --posix  # avoid changing the LD_LIBRARY_PATH again by sourcing configuration file

This will run your program only with your selected Qt installation without affecting other programs installed in your system. If you don't care about that, then you can add this in your shell profile or bashrc, etc., depending on what shell you use.

One more thing: if your program loads via links, i.e. libQtCore.so or libQtCore.so.5, etc, then you'll need to create those links too in the "my Qt libs location", if they are not already there.

Hope this helps.

Upvotes: 1

Related Questions