|
From: Lorenzo B. <be...@ds...> - 2009-03-08 14:07:59
|
Tor Lillqvist wrote: >> You mean that gcc does like that for determining its own path? > > It could, but it doesn't. As far as I could see gcc instead seems to > rely on argv[0] containing a full path to the gcc executable, or if > that is not the case, the executable being present in PATH. This of > course usually works fine, too. > > But note that you said "also for libraries". (Presumably meaning > *shared* libraries.) For a shared library to find out where it is > located there is no argv[0] to use. You must use ifdefs as the name of > a shared library file is different on different platforms, and the > environment variable that tells where to search for shared libraries > is different (PATH, LD_LIBRARY_PATH, SHLIB_PATH, DYLD_PATH, others?). > > Also, actually you of course can't be sure that the library was found > using such an environment variable directed mechanism. It might have > been found in a system-dependent standard location (%WINDIR%/system32, > %WINDIR%, the current directory, the folder where the .exe is, > /usr/lib, /usr/lib64, etc) or have been loaded using an explicit path > either programmatically or by the executable file format specifying an > explicit path or additional search path. And as you need ifdefs > anyway, why not just then in the case of Windows use the simple > DllMain() (to save the DLL handle) and GetModuleFileName() method. OK, then we're back to hardcode the path where the library (since from what I read above, there's no easy and reliable way to detect the right path) will be installed, and back to my problem that the path /usr/local will not work for fopen... -- Lorenzo Bettini, PhD in Computer Science, DI, Univ. Torino ICQ# lbetto, 16080134 (GNU/Linux User # 158233) HOME: http://www.lorenzobettini.it MUSIC: http://www.purplesucker.com http://www.myspace.com/supertrouperabba BLOGS: http://tronprog.blogspot.com http://longlivemusic.blogspot.com http://www.gnu.org/software/src-highlite http://www.gnu.org/software/gengetopt http://www.gnu.org/software/gengen http://doublecpp.sourceforge.net |