[Solved] How to make relative Qt library path in linux?
In Windows deployment, place Qt lib files (*.dll) in same folder with .exe works fine.
In Mac, we can make relative library address to executable binary files.
ႈIn Linux, it needs to deploy library files (*.so) into /usr/lib/..
Is there any methods, to place relative address from binary file to library files like in Windows?
"This":http://labs.qt.nokia.com/2011/10/28/rpath-and-runpath/ article might help you - and "RPATH":http://en.wikipedia.org/wiki/Rpath in general.
[quote author="zither" date="1320502037"]Dear all,
In Linux, it needs to deploy library files (*.so) into /usr/lib/..
Is there any methods, to place relative address from binary file to library files like in Windows?[/quote]
In Linux, libraries are searched from system directories and directories specified in LD_LIBRARY_PATH environment variable. For security reasons, Linux does not normally search libraries from user directories. You may modify it before loading your program - add "." to it, and libraries are searched from current working directory:
@$ LD_LIBRARY_PATH=. ./myProgram@
If you want to make a program that does it automatically, start your program from script, or write a program to modify the variable and then launch the actual program.
Use $ORIGIN in the executable's rpath. For example, add the following to your qmake project file.
QMAKE_LFLAGS += -Wl,--rpath=\$$ORIGIN
Setting the QMAKE_RPATH clears the default rpath setting for the Qt libraries. This allows for bundling the Qt libraries with the application. If you want the rpath to include the path to the Qt libraries, don’t set QMAKE_RPATH.
The way I want is to make relative address to application without effecting system variables.
I solve the problem with @Bradley said.
Thanks to all
BorisSclauzero last edited by
[quote author="zither" date="1320502037"]In Mac, we can make relative library address to executable binary files.[/quote]
Can you explain me how to do this?
It's about two days that I am stuck with this problem.
Thanks in advance
SGaist Lifetime Qt Champion last edited by
Please don't revive old thread that are almost 3 years old.
That said, have a look at the install_name_tool command. It's what is used on OS X (and e.g. macdeployqt)