Solving some "Symbol not found" problems for libJPEG, libTIFF, libGL, libPng

Robert Baruch robert.c.baruch at gmail.com
Thu Nov 18 11:57:53 PST 2010


Hi all,

To save some of you some time, if you run something and you get an error like this:

dyld: Symbol not found: _gll_noop 
  Referenced from: 
/System/Library/Frameworks/OpenGL.framework/Versions/A/OpenGL 
  Expected in: /opt/local/lib/libGL.dylib

or this:

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 

or this:

dyld: lazy symbol binding failed: Symbol not found: __cg_TIFFSetErrorHandler
Referenced from: /System/Library/Frameworks/ApplicationServices.framework/Versions/A/Frameworks/ImageIO.framework/Versions/A/ImageIO
Expected in: /opt/local/lib/libTIFF.dylib

or this:
dyld: Symbol not found: __cg_png_create_info_struct
  Referenced from: /System/Library/Frameworks/ApplicationServices.framework/Versions/A/Frameworks/ImageIO.framework/Versions/A/ImageIO
  Expected in: /optlocal/lib/libPng.dylib
Then congratulations, you've discovered that OSX and MacPorts are incompatible with each other for these libraries! For example, Macport's libjpeg contains the symbol _jpeg_resync_to_restart, but not what Apple is looking for, __cg_jpeg_resync_to_restart.

I have seen several solutions, including "removing any DYLD_LIBRARY_PATH" (which doesn't help when you don't have it set), and "removing the offending macports library", which doesn't help when it will just get reinstalled when you try to install a port which has those libraries as a dependency.

The solution that worked for me was this (note that if you don't have a particular /opt/local/lib library then you don't need that line)

sudo ln -sf /System/Library/Frameworks/OpenGL.framework/Versions/A/Libraries/libGL.dylib /opt/local/lib/libGL.dylib

sudo ln -sf /System/Library/Frameworks/ApplicationServices.framework/Versions/A/Frameworks/ImageIO.framework/Versions/A/Resources/libPng.dylib /opt/local/lib/libpng.dylib

sudo ln -sf /System/Library/Frameworks/ApplicationServices.framework/Versions/A/Frameworks/ImageIO.framework/Versions/A/Resources/libTIFF.dylib /opt/local/lib/libtiff.dylib

sudo ln -sf /System/Library/Frameworks/ApplicationServices.framework/Versions/A/Frameworks/ImageIO.framework/Versions/A/Resources/libJPEG.dylib /opt/local/lib/libjpeg.dylib

Why does this work? Because for whatever reason, when Apple requests libJPEG.dyld, whatever system searches for it finds /opt/local/lib/libjpeg.dyld because the search is case insensitive. For a Unix operating system. Go figure. The lines above will force any program looking for libjpeg.dyld to be redirected to Apple's libJPEG.dyld.

But wait, what if you WANT Macport's libjpeg.dyld? Sorry, not possible unless you statically link your program to libjpeg.a. And since I've never done that before, I can't help you if you want to do that :(

--Rob


More information about the macports-users mailing list