Re: Having trouble with -dylib_file
Re: Having trouble with -dylib_file
- Subject: Re: Having trouble with -dylib_file
- From: Jeff Schriebman <email@hidden>
- Date: Tue, 6 Jan 2009 13:02:57 -0800
Hello Wade,
Thanks for the information.
I tried your solution number 2 but without rebuilding the library.
Instead I simply copied the existing library into my application
bundle and invoked install_name_tool -change as you suggested.
Using this approach my application now finds the libpng.3.dylib that
is in the application bundle but the loader is still not finding what
it needs.
The following is the loader failure message that appears on 10.4
dyld: Library not loaded: @executable_path/../Frameworks/libpng.3.dylib
Referenced from: /Users/jeff/Desktop/MyApp.app/Contents/MacOS/MyApp
Reason: no suitable image found. Did find:
/Users/jeff/Desktop/MyApp.app/Contents/MacOS/../Frameworks/libpng.
3.dylib: can't map
/Users/jeff/Desktop/MyApp.app/Contents/MacOS/../Frameworks/libpng.
3.dylib: can't map
Is there an easy solution to this or must I rebuild the library?
If I rebuild the library I could simply just link it directly into my
application instead of making it a separate dylib.
The libpng file that is failing is a universal binary.
On Jan 5, 2009, at 10:24 PM, Wade Williams wrote:
You don't want -dylib_file.
The path to the library is stored within the library and then copied
to your application during linking. This is why your application is
still looking in the wrong directory.
There are two solutions:
1) Build the library so that it references a proper path for
bundling the library inside your application bundle. To do this,
get the source to libpng and modify the Makefile so that it compiles
with the -install_name flag set to @executable_path/../Frameworks/
libpng.3.dylib. This will build the library with
"@executable_path/../Frameworks/libpng.3.dylib" recorded as the
install location. Then you add the library to your application and
add a build step to copy it into the Frameworks folder of your
application bundle
2) If you have a library that has a massively convoluted build
process and it's not possible to easily modify the Makefile to build
an embeddable version of the library, you build the library
normally, add it to your project and again, add a build phase that
copies it to your application's Framework folder in the bundle.
Then you setup a shell script phase that runs the install_name_tool
to change the path that was recorded inside your application. So
something like "install_name_tool -change /usr/lib/libpng.3.dylib
@executable_path/../Frameworks/libpng.3.dylib MyApp.app/Contents/
MacOS/MyApp
See "man install_name_tool" for more information.
Hope this helps,
Wade
Regards,
Jeff Schriebman
Leapfrog Productions 415-499-5609
_______________________________________________
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