Recently, I unsuccessfully tried to install a series of badly written software in a hacky way (won't bore you with the details) and now it seems my OS X (Lion, 10.7.5) system files are a mess. I'll try to keep it brief.

Main problems:

1) Not being able to open any software from the Terminal because of dyld error messages

2) Having two versions of libiconv installed, one of them too old and the other incomplete, and struggling to resolve the situation

First example of 1): running some software (installed long ago) which I think requires XCode and such and is Python based results in this:

ImportError: dlopen(/opt/local/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/glib/_glib.so, 2): Library not loaded: /opt/local/lib/libiconv.2.dylib
Referenced from: /opt/local/lib/libgobject-2.0.0.dylib
Reason: Incompatible library version: libgobject-2.0.0.dylib requires version 8.0.0 or later, but libiconv.2.dylib provides version 7.0.0

However, otool reveals that /opt/local/lib/libiconv.2.dylib is version 8.1.0. I think this is the version installed by MacPorts.


$ otool -L /usr/lib/libiconv.2.dylib
/usr/lib/libiconv.2.dylib (compatibility version 7.0.0, current version 7.0.0)

So I think I have an old version (7.0.0) to which the software that I'm trying to run refers by mistake. I'm hesitant to re-install the software because a guru friend who is now on the other side of the world helped me with it (it's not been tested on OS X and I think he created a binary and who knows what else.) But in any case, I get messages like this for pretty much everything I'm trying to run from the command line, so I don't know if it's simply a case of having to re-install all my software.

Apparently I need to get iconv's newest version, this should update libiconv? So I got the newest iconv (1.14) by downloading and configuring - perhaps it will overwrite that old 7.0.0 libiconv version? But no:

$ ./configure --prefix=/usr/lib
dyld: Library not loaded: /opt/local/lib/libiconv.2.dylib
Referenced from: /opt/local/lib/libintl.8.dylib
Reason: Incompatible library version: libintl.8.dylib requires version 8.0.0 or later, but libiconv.2.dylib provides version 7.0.0

And I'm still on the old version:

$ /usr/bin/iconv --version
iconv (GNU libiconv 1.11)

If I simply try to use MacPorts to uninstall iconv:

$ sudo port uninstall iconv

There is no message, so it seems that it worked, but the binary is still there, and I still get the same messages. But that conflicts with this:

$ sudo port upgrade iconv
Error: iconv is not installed

$ sudo port install iconv
Error: Port iconv not found

I have experimented with the DYLD_LIBRARY_PATH and DYLD_FALLBACK_LIBRARY_PATH environment variables in my ~/.profile. I get errors either way, right now they are commented out.

Perhaps this would be enough information for a possible solution, but I'll give some more info here just in case.

  • I have updated my MacPorts very recently (selfupdate and upgrade outdated).
  • System architecture is x86-64
  • Another error message when I try to open Sublime Edit 2 from the command line:

dyld: Symbol not found: __cg_jpeg_resync_to_restart Referenced from: /System/Library/Frameworks/ApplicationServices.framework/Versions/A/Frameworks/ImageIO.framework/Versions/A/ImageIO Expected in: /opt/local/lib/libJPEG.dylib in /System/Library/Frameworks/ApplicationServices.framework/Versions/A/Frameworks/ImageIO.framework/Versions/A/ImageIO Trace/BPT trap: 5

$ otool -L /opt/local/lib/libJPEG.dylib
/opt/local/lib/libJPEG.dylib: /opt/local/lib/libjpeg.9.dylib (compatibility version 11.0.0, current version 11.0.0)
/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 159.1.0)

$ otool -L /System/Library/Frameworks/ApplicationServices.framework/Versions/A/Frameworks/ImageIO.framework/Versions/A/ImageIO | grep "libJPEG*"
/System/Library/Frameworks/ApplicationServices.framework/Versions/A/Frameworks/ImageIO.framework/Versions/A/Resources/libJPEG.dylib (compatibility version 1.0.0, current version 1.0.0)

No libJPEG.dylib on /usr/lib.

Thanks for reading this far! :)

1 Answer 1


Please unset any DYLD_* variables you have set in your environment. They are at least causing some of the problems you see. A system framework (such as ImageIO.framework) cannot reference binaries installed by MacPorts, but your error message shows System/Library/Frameworks/ApplicationServices.framework/Versions/A/Frameworks/ImageIO.framework/Versions/A/ImageIO is loading /opt/local/lib/libJPEG.dylib. That's because you likely have DYLD_LIBRARY_PATH set which overrides the default libjpeg path from the binary (which is /System/Library/Frameworks/ImageIO.framework/Versions/A/Resources/libJPEG.dylib).

Then, ensure that /opt/local/lib/libiconv.2.dylib exists. If it does not, please install it using sudo port install libiconv. If you want to make sure you're not going to see more errors like this, run sudo port rev-upgrade to automatically check for and fix such problems.

Oh, and please don't install stuff into /usr/lib manually. That's Apple-land, you should never modify it. It would only be overwritten on the next OS update anyway.

  • 1
    Hammer on the nail. Never would have dreamed that it would be as simple as typing "unset DYLD_LIBRARY_PATH". I didn't realize that uncommenting it in .profile would not have the same effect. By the way, the .dylib file exists, and rev-upgrade didn't reveal anything else. The first program still gives warnings but opens after some time. But as I said, it hasn't been developed for or tested on OS X (although I haven't had those warnings before). Thanks so much, and by the way, I love your username!
    – Gideon
    Apr 3, 2014 at 7:12
  • Though not related to the question above, the error I was getting was the same. Google landed me up here and did solved it. I'd exported it in my ~/.zshrc file as export DYLD_LIBRARY_PATH=/usr/local/lib which was throwing me the error while using subl binary for SublimeText3. Commenting it out as @neverpanic suggested did the trick.
    – millisami
    Oct 13, 2016 at 3:18

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .