I may be a bit presumptuous having my first post in Advanced but I am struggling with getting dylibs to load. I am trying to update the addon ofxASR (http://code.google.com/p/ofxasr/) speech recog to work with OF 73/74/XCODE4.
It works fine with OF 62/XCODE3. There are two dylibs that are needed and otool shows:
dyld: Library not loaded: @executable_path/libs3decoder.dylib
Referenced from: /Users/tom/openFrameworks/of_v0073_osx_release/apps/playgroundApps/ASRwithMoreBrains/bin/ASRwithMoreBrainsDebug.app/Contents/MacOS/ASRwithMoreBrainsDebug
Reason: image not found
If I manually add the dylibs to use/lib it works/loads.
I have tried to reconfig the addon using the ofxAddonTemplate as a reference but dylibs are not explained. I am looking at gameoverhack/ofxOpenNI as an example of an addon that uses many dylibs but it uses complex scripts/modules and having to drag the dylibs to the add-on in Xcode. Other examples talk about adding to the target/build phases/run script such as is used for libfmodex.dylib but that seems xcode centric and not that portable.
What is the best way to handle 3rd party dylibs and have a portable addon solution once it is complete?
dyld: Library not loaded: @executable_path/libs3decoder.dylib
Referenced from: /Users/tmisage/openFrameworks/of_v0073_osx_release/apps/playgroundApps/ASRwithMoreBrains/bin/ASRwithMoreBrainsDebug.app/Contents/MacOS/ASRwithMoreBrainsDebug
Reason: image not found
I was able to get the dylibs loaded and working by doing two things:
adding to the run script under Targets / Build Phases
# copy libfmodex.dylib to package target directory so self contained
cp -f ../../../libs/fmodex/lib/osx/libfmodex.dylib "$TARGET_BUILD_DIR/$PRODUCT_NAME.app/Contents/MacOS/libfmodex.dylib";
# change orig path of ./libfmodex.dylib
install_name_tool -change ./libfmodex.dylib @executable_path/libfmodex.dylib "$TARGET_BUILD_DIR/$PRODUCT_NAME.app/Contents/MacOS/$PRODUCT_NAME";
# copy libs3decoder.dylib to package target directory so self contained
cp -f ../../../addons/ofxASR/libs/sphinx/lib/osx/libs3decoder.dylib "$TARGET_BUILD_DIR/$PRODUCT_NAME.app/Contents/MacOS/libs3decoder.dylib";
# Optional - seems to work with or without it - change orig path of ./libfmodex.dylib
install_name_tool -change ./libs3decoder.dylib @executable_path/libs3decoder.dylib "$TARGET_BUILD_DIR/$PRODUCT_NAME.app/Contents/MacOS/$PRODUCT_NAME";
# copy libsphinxbase.dylib to package target directory so self contained
cp -f ../../../addons/ofxASR/libs/sphinx/lib/osx/libsphinxbase.dylib "$TARGET_BUILD_DIR/$PRODUCT_NAME.app/Contents/MacOS/libsphinxbase.dylib";
# Optional - seems to work with or without it - change orig path of @executable_path/libfmodex.dylib to target directory
install_name_tool -change ./libsphinxbase.dylib @executable_path/libsphinxbase.dylib "$TARGET_BUILD_DIR/$PRODUCT_NAME.app/Contents/MacOS/$PRODUCT_NAME";
I am presuming that this copies the dylibs to the contents/MacOS folder of the package. The actual install_tool_change command seems optional in my case I believe because the dylib path is already
@executable_path/libs3decoder.dylib
dragging the dylib to the root of the Xcode project in the left side file hierarchy window in Xcode. I assume this if giving the linker the path to the libs during compile time …
Even though it is working I am still interested in if this is “standard procedure” for how one should deal with dylibs in open frameworks? It seems to break the desire to “copy the add-on to the add-on folder and then use project generator to make a generic project that has all the necessary links”…
Hi Eltoro
Thanks so much for this explanation. It was exactly what I was struggling with and was looking for.
Haven’t tested it extensively (like on other machines) but I used it with MediaInfo dylib and I think it worked just fine.
Many thanks
fakob