[Qt-interest] Setting library path before running?

Oliver.Knoll at comit.ch Oliver.Knoll at comit.ch
Tue Mar 23 16:19:30 CET 2010


william.crocker at analog.com wrote on Tuesday, March 23, 2010 4:08 PM:

> Brad Howes wrote:
>> On Mar 23, 2010, at 7:53 AM, Oliver.Knoll at comit.ch wrote:
>> 
>>> william.crocker at analog.com wrote on Tuesday, March 23, 2010 11:37
>>> AM: 
>>> 
>>>> ...
>>>> We run our apps through a wrapper script which sets LD_LIBRARY_PATH
>>>> first.
>>> You can also include the '.' (current directory) to the "build-in"
>>> library paths of the executable. Read about the -rpath linker
>>> option (and you can set this via qmake/*.pro files, too).  
>> 
>> 
>> Note that some platforms, notably Solaris IIRC, do not follow
>> relative links due to potential security issues. 

Hmmm, good point. But I remember we had our application running like this (-rpath ./lib), but I think that was on SunOS 4 (already at that time SunOS 5 was available). So is this a new feature of the latest Solaris...errr... okay, so I got it: http://en.wikipedia.org/wiki/SunOS

Up to SunOS 4 it was called "SunOS", after 5 it became "Solaris".

>> To be safe, use
>> $PWD or $(pwd) to insert the current directory. Not sure of the
>> qmake syntax, but I'm sure there is an appropriate variable to use
>> to fetch it. 

But that requires you to link the application in the place where it is later to be run, right? Such as in /usr/bin, /usr/local/bin or /opt/FooCompany/MyApp... or you would specify -rpath /usr/local/bin right away...
   
> And, in the rare event that your app will be running as root (like
> mine does) then the rules change again. No LD_LIBRARY_PATH, for
> example.

*And* in the case you want to set -rpath on AIX, you also have at least to specify /usr/lib. It seems that simply saying -rpath . "overrides" all default linker paths, so it should be -rpath /usr/lib,.  

;)

Cheers, Oliver

-- 
Oliver Knoll
Dipl. Informatik-Ing. ETH
COMIT AG - ++41 79 520 95 22



More information about the Qt-interest-old mailing list