Some will find LD_LIBRARY_PATH variable usefull, but it can become a real pain (e.g, if you need to elevate your process).
A better and more reliable solution is to tell compiler about libraries locations at link time using -rpath key, like this:
-Wl,-rpath,/some/path/to/libThere is also a way to set a path relative to a location of an executable by using $ORIGIN key-word.
-Wl,-rpath,'$ORIGIN/../mylibs'You might think: "This is perfect!" but problems are not over yet. If you're using qmake pro file to build a project then you need to path $ORIGIN keyword all the way down to compiler arguments through: first qmake pro file processor and then Makefile processor. Use this solution to avoid the string being interpreted at any step.
QMAKE_LFLAGS += '-Wl,-rpath,\'\$$ORIGIN/../mylibs\''Qmake provides QMAKE_RPATHDIR variable for defining a set of pathes. But it won't work with a path containing $ORIGIN as it will resolve it no matter how far away you hide it. Use QMAKE_LFLAGS instead.