Re: carrying dynamic library in app?
Re: carrying dynamic library in app?
- Subject: Re: carrying dynamic library in app?
- From: Todd Heberlein <email@hidden>
- Date: Sat, 05 Dec 2009 15:27:41 -0800
On Dec 4, 2009, at 1:40 PM, Dave Carrigan wrote:
> If your app is a bundle and you have the distribution rights, you can just bundle the dynamic libraries using a copy files phase. I usually put them inside Frameworks. You will probably need to also fix up the loader names using a Run Script phase, something like:
>
> install_name_tool -change /usr/local/lib/libgvc.dylib @loader_path/../Frameworks/libgvc.dylib "$BUILT_PRODUCTS_DIR/$EXECUTABLE_PATH"
Thanks Dave! With those direction I also found a good example here:
http://brockwoolf.com/how-to-use-dynamic-libraries-in-xcode-31-using-fmod
It turns out that two of the Graphviz dynamic libraries also depended on other dynamic libraries, so I needed repeat the install_name_tool command on the libraries themselves. In case someone runs into this problem and finds this thread, below is my "Run Script" that gets called at the end of the build.
Todd
#
# Create Frameworkds directory into which to copy the dynamic libraries
#
if [ ! -d "$TARGET_BUILD_DIR/$PRODUCT_NAME.app/Contents/Frameworks" ]; then
mkdir "$TARGET_BUILD_DIR/$PRODUCT_NAME.app/Contents/Frameworks"
fi
#
# Copy the Graphviz dynamic libraries into the app's Frameworks directory
#
cp -f /usr/local/lib/libgvc.5.dylib "$TARGET_BUILD_DIR/$PRODUCT_NAME.app/Contents/Frameworks/libgvc.5.dylib"
cp -f /usr/local/lib/libgraph.4.dylib "$TARGET_BUILD_DIR/$PRODUCT_NAME.app/Contents/Frameworks/libgraph.4.dylib"
cp -f /usr/local/lib/libpathplan.4.dylib "$TARGET_BUILD_DIR/$PRODUCT_NAME.app/Contents/Frameworks/libpathplan.4.dylib"
cp -f /usr/local/lib/libcdt.4.dylib "$TARGET_BUILD_DIR/$PRODUCT_NAME.app/Contents/Frameworks/libcdt.4.dylib"
cp -f /usr/local/lib/libxdot.4.dylib "$TARGET_BUILD_DIR/$PRODUCT_NAME.app/Contents/Frameworks/libxdot.4.dylib"
#
# Tell the application to find the dynamic libraries in our Frameworks directory
#
install_name_tool -change /usr/local/lib/libgvc.5.dylib @loader_path/../Frameworks/libgvc.5.dylib "$TARGET_BUILD_DIR/$PRODUCT_NAME.app/Contents/MacOS/$PRODUCT_NAME"
install_name_tool -change /usr/local/lib/libgraph.4.dylib @loader_path/../Frameworks/libgraph.4.dylib "$TARGET_BUILD_DIR/$PRODUCT_NAME.app/Contents/MacOS/$PRODUCT_NAME"
install_name_tool -change /usr/local/lib/libpathplan.4.dylib @loader_path/../Frameworks/libpathplan.4.dylib "$TARGET_BUILD_DIR/$PRODUCT_NAME.app/Contents/MacOS/$PRODUCT_NAME"
install_name_tool -change /usr/local/lib/libcdt.4.dylib @loader_path/../Frameworks/libcdt.4.dylib "$TARGET_BUILD_DIR/$PRODUCT_NAME.app/Contents/MacOS/$PRODUCT_NAME"
install_name_tool -change /usr/local/lib/libxdot.4.dylib @loader_path/../Frameworks/libxdot.4.dylib "$TARGET_BUILD_DIR/$PRODUCT_NAME.app/Contents/MacOS/$PRODUCT_NAME"
#
# Tell the libgvc.5.dylib to find the other graphviz libraries in our Framework directory
#
install_name_tool -change /usr/local/lib/libxdot.4.dylib @loader_path/../Frameworks/libxdot.4.dylib "$TARGET_BUILD_DIR/$PRODUCT_NAME.app/Contents/Frameworks/libgvc.5.dylib"
install_name_tool -change /usr/local/lib/libcdt.4.dylib @loader_path/../Frameworks/libcdt.4.dylib "$TARGET_BUILD_DIR/$PRODUCT_NAME.app/Contents/Frameworks/libgvc.5.dylib"
install_name_tool -change /usr/local/lib/libgraph.4.dylib @loader_path/../Frameworks/libgraph.4.dylib "$TARGET_BUILD_DIR/$PRODUCT_NAME.app/Contents/Frameworks/libgvc.5.dylib"
install_name_tool -change /usr/local/lib/libpathplan.4.dylib @loader_path/../Frameworks/libpathplan.4.dylib "$TARGET_BUILD_DIR/$PRODUCT_NAME.app/Contents/Frameworks/libgvc.5.dylib"
#
# Tell the libgraph.4.dylib to find the libcdt library in our Framework directory
#
install_name_tool -change /usr/local/lib/libcdt.4.dylib @loader_path/../Frameworks/libcdt.4.dylib "$TARGET_BUILD_DIR/$PRODUCT_NAME.app/Contents/Frameworks/libgraph.4.dylib"
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Xcode-users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden