[Qt-interest] Linux Deployment using rpath and $ORIGIN
Joshua Grauman
jnfo-c at grauman.com
Sat Dec 11 21:03:45 CET 2010
Hello all,
I've read the Qt docs about deploying Qt under Linux. It gives the following
three ways to deploy the libraries when using dynamic linking. I was wondering
if the best option isn't even mentioned here. I just read that rpath can take
$ORIGIN as an option which looks for libraries in the directory of the
executable. Wouldn't that avoid all the disadvantages listed below, and not
require the use of a startup script separate from the executable? Couldn't a
simple tool called linuxdeployqt (similar to the Mac one) be created to set the
rpath of the executable to $ORIGIN, and copy the libs to that directory?
Wouldn't this possibly also avoid the setuid problem listed below?
Thanks!
Josh
>From the docs:
You can install the Qt libraries in one of the system library paths (e.g.
/usr/lib on most systems).
You can pass a predetermined path to the -rpath command-line option when
linking the application. This will tell the dynamic linker to look in this
directory when starting your application.
You can write a startup script for your application, where you modify the
dynamic linker configuration (e.g. adding your application's directory to the
LD_LIBRARY_PATH environment variable. Note: If your application will be running
with "Set user ID on execution," and if it will be owned by root, then
LD_LIBRARY_PATH will be ignored on some platforms. In this case, use of the
LD_LIBRARY_PATH approach is not an option).
The disadvantage of the first approach is that the user must have super user
privileges. The disadvantage of the second approach is that the user may not
have privileges to install into the predetemined path. In either case, the
users don't have the option of installing to their home directory. We recommend
using the third approach since it is the most flexible.
More information about the Qt-interest-old
mailing list