Apple Intelligence is now available on iPhone, iPad, and Mac!

Looks like no one’s replied in a while. To start the conversation again, simply ask a new question.

Modifying DYLD_LIBRARY_PATH

I'm not much of a Unix person; I only just started learning to use Darwin a week ago. I'm trying to install imagemagick, which needs to add its 'lib' path to DYLD LIBRARYPATH in order to work.

As I understand it, DYLD LIBRARYPATH is a colon separated list of directories that Darwin searches when a process asks for a library. That makes sense, but I can't figure out how to add imagemagick's library to the list. The export command will only work for the session I use it in (in which case imagemagick will work just fine), but no other process can use it. The man pages for the tools I think are supposed to let me modify the variable are very advanced, and I didn't want to do anything without human guidance.

Thanks for everyone's help.

iMac Intel Core Duo, Mac OS X (10.5.4)

Posted on Aug 18, 2008 8:23 PM

Reply
Question marked as Top-ranking reply

Posted on Aug 30, 2008 4:10 PM

export DYLD_LIBRARY_PATH=/path/to/imagemagick/library:${DYLD_LIBRARY_PATH}

will add to the variable rather than replacing it. So if other things need to find things on the path, they should be able to.

To get it to persist from session to session, you can create a shell configuration file in your home directory and put the export command in there. For bash, you can use .bashrc (which should get read even by shell scripts). Note the dot at the start. You won't be able to see the file in Finder unless you set Finder to show all files. But you will be able to see it in Terminal using "ls -a" rather than plain "ls".
4 replies
Question marked as Top-ranking reply

Aug 30, 2008 4:10 PM in response to Homestar

export DYLD_LIBRARY_PATH=/path/to/imagemagick/library:${DYLD_LIBRARY_PATH}

will add to the variable rather than replacing it. So if other things need to find things on the path, they should be able to.

To get it to persist from session to session, you can create a shell configuration file in your home directory and put the export command in there. For bash, you can use .bashrc (which should get read even by shell scripts). Note the dot at the start. You won't be able to see the file in Finder unless you set Finder to show all files. But you will be able to see it in Terminal using "ls -a" rather than plain "ls".

Aug 30, 2008 7:13 PM in response to Homestar

It is actually best to avoid setting this variable if you possibly can.

The binary should have the path to the associated libraries hard-coded into it, eg:


% otool -L /sw/bin/convert
/sw/bin/convert:
/System/Library/Frameworks/ApplicationServices.framework/Versions/A/ApplicationServices (compatibility version 1.0.0, current version 34.0.0)
/sw/lib/libMagickCore.1.dylib (compatibility version 2.0.0, current version 2.0.0)
/sw/lib/libMagickWand.1.dylib (compatibility version 2.0.0, current version 2.0.0)
/sw/lib/liblcms.1.dylib (compatibility version 2.0.0, current version 2.15.0)
/sw/lib/libtiff.3.dylib (compatibility version 12.0.0, current version 12.2.0)
/sw/lib/libjpeg.62.dylib (compatibility version 63.0.0, current version 63.0.0)
/usr/X11/lib/libfontconfig.1.dylib (compatibility version 5.0.0, current version 5.0.0)
/usr/lib/libiconv.2.dylib (compatibility version 7.0.0, current version 7.0.0)
/sw/lib/libexpat.1.dylib (compatibility version 7.0.0, current version 7.2.0)
/usr/X11/lib/libXext.6.dylib (compatibility version 11.0.0, current version 11.0.0)
/usr/X11/lib/libXt.6.dylib (compatibility version 7.0.0, current version 7.0.0)
/sw/lib/libbz2.1.dylib (compatibility version 1.0.1, current version 1.0.5)
/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 111.1.1)
/sw/lib/freetype219/lib/libfreetype.6.dylib (compatibility version 10.0.0, current version 10.16.0)
/usr/lib/libz.1.dylib (compatibility version 1.0.0, current version 1.2.3)
/usr/X11/lib/libSM.6.dylib (compatibility version 7.0.0, current version 7.0.0)
/usr/X11/lib/libICE.6.dylib (compatibility version 10.0.0, current version 10.0.0)
/usr/X11/lib/libX11.6.dylib (compatibility version 9.0.0, current version 9.0.0)
/usr/X11/lib/libXau.6.dylib (compatibility version 7.0.0, current version 7.0.0)
/usr/X11/lib/libXdmcp.6.dylib (compatibility version 7.0.0, current version 7.0.0)
/usr/lib/libstdc++.6.dylib (compatibility version 7.0.0, current version 7.4.0)
/usr/lib/libgcc_s.1.dylib (compatibility version 1.0.0, current version 1.0.0)



As long as those libraries are in the correct directories, you don't need to set that variable (which will eventually cause trouble).

Sep 10, 2008 5:39 PM in response to Bill Scott

The same should go if you're installing in /usr/local, for example.

In some cases, I've found I have to temporarily adjust DYLD LIBRARYPATH to get a test suite to run prior to installation.

With earlier versions of OS X it did seem necessary to adjust the variable - and to readjust it when necessary - but I haven't found that on Tiger, at least.

What makes you think you need to adjust the path for ImageMagick?

- cfr

Modifying DYLD_LIBRARY_PATH

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.