P
P
pixik2015-10-29 14:30:06
linux
pixik, 2015-10-29 14:30:06

How to slip the path to another library in linux before executing the program?

Good time!
The program is assembled in qt creator, and takes the paths to the required library from the *.pro file. But if the program is run from the console, then it takes the paths to the libraries from ldconfig.
There is an idea to write a bash script that creates a certain symlink or something else so that the program works with the required library. Where can I specify where the program should take the path to the library from?
Thanks to all! I apologize for my delusion.

Answer the question

In order to leave comments, you need to log in

4 answer(s)
O
Oleg Tsilyurik, 2015-10-29
@pixik

But if the program is run from the console, then it takes the paths to the libraries from ldconfig.

In fact, the name resolution algorithm both at the build stage and at the run stage is much more extensive and interesting ... but for some reason this is not very well known, and beautiful folk legends about this are running around the network. For a more or less detailed list of features, see Developing Software Projects on Linux (p. 53 onwards ... about libraries).
It is possible, but such a script is rather meaningless - using LD_LIBRARY_PATH, LD_RUN_PATH and other methods, you can always determine (by regular means!) Which libraries to use.
And "where does the program get the path to the library from?" - it's in the link above.

A
Axian Ltd., 2015-10-29
@AxianLTD

The most correct IMHO chroot

X
xibir, 2015-10-29
@xibir

using the LD_LIBRARY_PATH variable, you can set the paths to libraries

M
Maxim Moseychuk, 2015-10-29
@fshp

LD_PRELOAD

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question