[Qt-interest] Setting library path before running?

Clinton Stimpson clinton at elemtech.com
Tue Mar 23 15:26:03 CET 2010


On 03/23/2010 05: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).
>
> Or you can also set something like ./lib as rpath, then your app will look in the subfolder lib for libraries, so given:
>
> gcc -rpath ./lib ...    // or similar, check man pages for exact syntax
>
> /path/to/my/app
> +- MyApp
> +- lib
>      +- libFoo.so
>
> That would work (without setting LD_LIBRARY_PATH to /path/to/my/app/lib!):
>
> $>  cd /path/to/my/app
> $>  ./MyApp
>
>
> Like this your executable will find all the shared libraries in the same folder (just like on Windows) - as long as the current directory is set at the point when starting the app (e.g. by a shell script, as suggested above - but that shell script does not need to care about LD_LIBRARY_PATH anymore :)!
>
>    

Or use $ORIGIN (on some platforms) in your rpath and not use a shell 
script at all.

Clint




More information about the Qt-interest-old mailing list