[Qt-interest] How Can I set a directory to search libraries in runtime ?
Oliver.Knoll at comit.ch
Oliver.Knoll at comit.ch
Mon Nov 9 10:01:36 CET 2009
Andreas Pakulat wrote on Monday, November 09, 2009 12:23 AM:
> ...
> That'll work on linux, on windows you'll simply have to make sure
> that your libraries are in a directory thats in PATH
On Windows you can also setup a registry entry here:
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\
Have a look at the existing examples. In the value 'Path' you can specify one or several paths which are added to the PATH as soon as the *.exe (as specified in the registry key) is executed.
For example when your foo.exe is located here:
c:\program files\yourcompany\yourapp\foo.exe
and your DLLs are located in a subdirectory thereof called 'lib', then your registry would become:
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\foo.exe
+- (Standard) REG_SZ c:\program files\yourcompany\yourapp\foo.exe
+- Path REG_SZ c:\program files\yourcompany\yourapp\lib\
See for example for more info:
http://www.codeguru.com/Cpp/W-P/dll/article.php/c99
Note though that after the DLL Hell(tm) Microsoft invented the Manifest Fiasko(tm); so with manifests there might be more elegant ways to specify where to look for your application's DLLs. Modifying the registry should be avoided if possible nowadays (even MS recommends to use e.g. application *.ini files, instead of storing application settings in the registry. Nevertheless I consider setting the App Path in the registry a valid approach).
For more Windows specific stuff: http://msdn.microsoft.com/en-us/library/ms682586%28VS.85%29.aspx (including links to manifests)
> and I have no
> idea about MacOSX.
Aren't applications compiled using gcc as well on MacOSX? So maybe the -rpath linker option works there as well? Since MacOSX is also Unixoid, setting the LD_LIBRARY_PATH (e.g. in a shell script which launches the actual binary) would work to (but this is considered not such a good solution).
But then again, I've heard of concepts such as "Application bundles", so it might work entirely different on MacOSX. Maybe http://doc.trolltech.com/4.5/deployment-mac.html sheds some light on it.
Oh by the way, from this day on, this evening to be specific, I have/can to deal with MacOSX as well - iMac world, here I come ;)
Cheers, Oliver
--
Oliver Knoll
Dipl. Informatik-Ing. ETH
COMIT AG - ++41 79 520 95 22
More information about the Qt-interest-old
mailing list