Re: Having trouble with -dylib_file
Re: Having trouble with -dylib_file
- Subject: Re: Having trouble with -dylib_file
- From: Wade Williams <email@hidden>
- Date: Fri, 16 Jan 2009 09:39:50 -0600
Just to finish this thread for the archives, an option I had forgotten
about which is easier than #2 below.
The install_name_tool also supports a -init flag. This allows you to
change the recorded path in the library, which is much more simple
than a shell script phase to change the recorded path in the final
application.
So just building the library with the default installation path and
then running install_name_tool -init @executable_path/../Frameworks/
<library name> <library>
will do the job nicely.
Wade
On Jan 6, 2009, at 7:18 PM, Jeff Schriebman wrote:
Thanks Wade.
That was exactly what it was.
Somewhere along the way I switched to using the stub instead of the
actual library and when I switched to using the proper libpng.
3.dylib in conjunction with install_name_tool my application runs
fine on OS X 10.4 with the library in the application bundle.
Problem solved.
On Jan 6, 2009, at 2:45 PM, Wade Williams wrote:
Jeff,
Never seen that error before. My first suspicion would be that's
not a valid library and is just a stub.
What's the output when you run the "file" command on the library?
i.e. "file libpng.3.dylib"
Wade
On Jan 6, 2009, at 3:02 PM, Jeff Schriebman wrote:
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
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