Being new to OSX development, I’m still getting a handle on some of the finer points of library management in Xcode. Today I learned all about .dylibs and thought I might throw a note in here for the next poor n00b who gets ofxTurboJpeg working fine in debug mode, but can’t launch the .app itself and distribute the executable:
I kept getting an error:
Library not loaded: libturbojpeg.dylib
Reason: image not found
I tried putting the library everywhere in the bundled package. No good. Couldn’t find it. So through much trial and error I discovered the solution:
Under the project settings, Build Phases tab, Run Script heading, there is part of a script that looks like this:
cp -f ../../../libs/fmodex/lib/osx/libfmodex.dylib "$TARGET_BUILD_DIR/$PRODUCT_NAME.app/Contents/MacOS/libfmodex.dylib"; install_name_tool -change ./libfmodex.dylib @executable_path/libfmodex.dylib "$TARGET_BUILD_DIR/$PRODUCT_NAME.app/Contents/MacOS/$PRODUCT_NAME";
In order to properly copy in libturbojpeg.dylib AND let it and the executable know where it is, add this:
cp -f ../../../addons/ofxTurboJpeg/libs/turbo-jpeg/lib/osx/libturbojpeg.dylib "$TARGET_BUILD_DIR/$PRODUCT_NAME.app/Contents/MacOS/libturbojpeg.dylib"; install_name_tool -change libturbojpeg.dylib @executable_path/libturbojpeg.dylib "$TARGET_BUILD_DIR/$PRODUCT_NAME.app/Contents/MacOS/$PRODUCT_NAME"
Rock and roll.
There are some things that Xcode makes much more pleasant than VS. This was not one of those things.