Library search paths, daemon startupitem and launchd

Tom Davis tomldavis at verizon.net
Mon Jan 25 21:52:31 PST 2010


So you're suggesting patching the launchd plist? That's the route I'm going down now, but I just don't know if its the "right" way. I have found a few ports that patch or create their own plist, but it doesn't seem very common.

I'm a real newbie to MacPorts and don't know the rules (both written and unwritten). 

Tom



On Jan 25, 2010, at 3:41 PM, Jeremy Lavergne wrote:

> It sounds like putting the DYLIB in the launchd.plist entirely avoids this problem for you though.
> 
> As Bradley suggested, checkout man launchd.plist for the settings afforded to you through the plist.  If it cannot help you, create a wrapper script that sets up your environment and then launches the binary.
> 
> On Jan 25, 2010, at 4:16 PM, Tom Davis wrote:
> 
>> Hello,
>> 
>> I'm trying to write a portfile for iguanaIR (http://iguanaworks.net/projects/IguanaIR). I'm having difficulties starting a daemon using startupitem.executable. When I try to start the daemon with:
>> 
>> 	sudo launchctl load -w /Library/LaunchDaemons/org.macports.iguanaIR.plist
>> 
>> igdaemon crashes. Here's part of the CrashReporter log:
>> 
>> 	Dyld Error Message:
>> 	  Library not loaded: libiguanaIR.dylib
>> 	  Referenced from: /opt/local/bin/igdaemon
>> 	  Reason: image not found
>> 
>> The libiguanaIR.dylib library is part of the iguanaIR distribution and is in /opt/local/lib after a port install. otool shows that libiguanaIR.dylib is the only library without an absolute path:
>> 
>> 	Rett:~ tom$ otool -L /opt/local/bin/igdaemon
>> 	/opt/local/bin/igdaemon:
>> 	/System/Library/Frameworks/CoreFoundation.framework/Versions/A/CoreFoundation (compatibility version 150.0.0, 			current version 550.13.0)
>> 	/System/Library/Frameworks/IOKit.framework/Versions/A/IOKit (compatibility version 1.0.0, current version 275.0.0)
>> 	libiguanaIR.dylib (compatibility version 1.0.0, current version 1.0.0)
>> 	/opt/local/lib/libpopt.0.dylib (compatibility version 1.0.0, current version 1.0.0)
>> 	/opt/local/lib/libusb-0.1.4.dylib (compatibility version 9.0.0, current version 9.4.0)
>> 	/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 125.0.0)
>> 
>> I'm guessing this is because it's not linked with the -l switch because libiguanaIR.dylib is not installed at the time igdaemon is built.
>> 
>> My .profile is setup to search /opt/local/lib for libraries:
>> 
>> 	Rett:~ tom$ env | grep LIB
>> 	DYLD_FALLBACK_LIBRARY_PATH=/opt/local/lib:
>> 	LIBRARY_PATH=/opt/local/lib
>> 	DYLD_LIBRARY_PATH=/Applications/MATLAB_R2009a.app/bin/mac:/Applications/MATLAB_R2009a.app/sys/os/mac:
>> 
>> If I run igdaemon from the command line, everything works fine. 
>> 
>> If I copy libiguanaIR.dylib to /usr/local/lib and use launchctl, everything works fine.  If I add the following lines to org.macports.iguanaIR.plist:
>> 
>> 	<key>EnvironmentVariables</key>
>> 	<dict>
>> 	 <key>DYLD_FALLBACK_LIBRARY_PATH</key> <string>/opt/local/lib</string>
>> 	 </dict>
>> 
>> or
>> 	<key>WorkingDirectory</key>
>> 	<string>/opt/local/lib</string>
>> 
>> then everything works fine. 
>> 
>> /Library/LaunchDaemons must be started by sudo, But sudo strips environmental variables such as DYLD_FALLBACK_LIBRARY_PATH for security reasons. 
>> 
>> So, what is the correct way to get a daemon to search /op/local/lib? Is there a way to add the EnvironmentVariables key to the launchctl plist using portfile settings? 
>> 
>> Tom
>> 
>> 
>> 
>> 
>> 
>> 
>> 
>> _______________________________________________
>> macports-dev mailing list
>> macports-dev at lists.macosforge.org
>> http://lists.macosforge.org/mailman/listinfo.cgi/macports-dev
>> 
> 



More information about the macports-dev mailing list