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

Referenced from:
/System/Library/Frameworks/OpenGL.framework/Versions/A/OpenGL
Expected in: /opt/local/lib/libGL.dylib

or this:

Referenced from:
/System/Library/Frameworks/ApplicationServices.framework/Versions/A/Frameworks/ImageIO.framework/Versions/A/ImageIO
Expected in: /opt/local/lib/libJPEG.dylib

or this:

Referenced from: /System/Library/Frameworks/ApplicationServices.framework/Versions/A/Frameworks/ImageIO.framework/Versions/A/ImageIO
Expected in: /opt/local/lib/libTIFF.dylib

or this:
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 :(