On 5 Dec 2006, at 02:07, Quentin Mathé wrote:
GNUSTEP_SYSTEM_ROOT, LD_LIBRARY_PATH etc.
Just to be able to launch tool like gpbs with NSTask and without
modifying PATH or using opentool. I would like to do the same for
an application like Gorm (I mean without using openapp). If I know
GNUSTEP_SYSTEM_ROOT, I can find them easily because tools or
applications I plan to launch won't be moved once installed.
However GNUSTEP_SYSTEM_ROOT may change depending on the user or
the machine, so I either need a way to know its value or an API
that allows to search for tool and application path in standard
locations like GNUSTEP_SYSTEM_ROOT and GNUSTEP_LOCAL_ROOT.
My daemonizer process is launched with a copy of libgnustep-base
put in /usr/lib because if I try to launch it without such copy,
it complains about libgnustep-base not available (not surprisingly
since it is installed by default in /System/Library/Libraries on
my machine).
So I was supposing that environment variables I just mention
weren't set for this process, but perhaps I make a wrong assumption?
1. When you install GNUstep, you should add the paths of the
directories containing GNUstep libraries to /etc/ld.so.conf and run
the ldconfig program to update the systems cache of library
paths. Putting libgnustep-base in /usr/lib has a similar effect,
but you need to remember to do that for every library you might
want to use ... so adding directories to /etc/ld.so.conf is less
error prone as it means you are less likely to miss a library.
2. Use the NSSearchPathForDirectoriesInDomains() function to get a
list (NSArray) of the directories that your tool may be in.
3. For each path in the list, call [NSString-
stringByAppendingPathComponent:] to add the program name to the
directory, call [NSFileManager-fileExistsAtPath:isDirectory:] to
see if the named program exists and if it is a directory.
4a. If the path you found is a directory (an app) ... use the
NSBundle API to access the directory bundle and determine the path
to the executable in the bundle, then pass that to NSTask to launch.
4b. If the path is not a directory, just use it as the launch path
for NSTask directly.