General OS X question: DYLD_LIBRARY_PATH and install name

Bryan Blackburn blb at macports.org
Wed Oct 29 14:49:08 PDT 2008


On Wed, Oct 29, 2008 at 10:30:17PM +0100, C. Florian Ebeling said:
> Hi,
> 
> I recently came across the statement that one needs to set the DYLD_LIBRARY_PATH
> variable if you want to run an executable linked against a dynamic
> library which is not to be found
> in any of the standard locations (~/lib:/usr/lib:/usr/local/lib). That
> is the case for all mp installed
> libraries, I'd say. My immediate reaction was that this is not true,
> and that everything is fine
> without the variable as long as `otool -L' points to the right
> location. So the "install name" counts.
> To be sure I reviewed some of the apple documentation [1][2], and that
> read quite like you _do_
> really need the variable. So what is the truth now? :) Please
> enlighten me. Do you really
> need a special environment at run time when you use a library
> installed by MacPorts? -- because
> that's what it comes down to, effectively.
> 

You might be commingling two different, but similar, ideas: an item
can be linked directly against a dylib (eg, what you see with 'otool -L')
and you can load a dylib (or bundle) at runtime using dlopen().

If 'otool -L' shows a given item linked against the right libs, then for
those you don't need to fool with any env variables.  dlopen(), I believe,
does need to know if you're installing items outside the standard locations.

Also, I believe that using the fallback version is preferred when one must
be used, there's been issues with the system having trouble finding stuff
when DYLD_LIBRARY_PATH was used.

Bryan


> (Add-on question: are dynamic libraries usually "dependent libraries"
> or are the "dynamically loaded
> libaries" -- and how do you tell?)
> 
> Cheers,
> Florian
> 
> [1] http://url.ie/ug8
> [2] http://url.ie/uga
> 
> 
> -- 
> Florian Ebeling
> Twitter: febeling
> florian.ebeling at gmail.com


More information about the macports-dev mailing list