Re: Problem with setting dylib paths to ship them in my app bundle
Re: Problem with setting dylib paths to ship them in my app bundle
- Subject: Re: Problem with setting dylib paths to ship them in my app bundle
- From: Ken Thomases <email@hidden>
- Date: Sat, 17 Apr 2010 04:23:47 -0500
I am redirecting this to the Xcode-users mailing list, because this has nothing to do with Cocoa.
On Apr 16, 2010, at 9:46 AM, Parimal Das wrote:
> I am using a third-party library, which has 2 dylibs in it.
> Say, libABC.dylib and libXYZ.dylib
>
> On doing a
> $ otool -L libABC.dylib
> libABC.dylib:
> libABC.dylib (compatibility version 1.0.0, current version 1.0.0)
> libXYZ.dylib (compatibility version 0.0.0, current version 0.0.0)
> /usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version
> 111.1.5)
>
> $ otool -L libXYZ.dylib
> libXYZ.dylib:
> libXYZ.dylib (compatibility version 0.0.0, current version 0.0.0)
> /usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version
> 111.1.5)
>
> Now i want to ship these dylibs, with my app.
> For that i have changed the dylib paths as
>
> $ install_name_tool -id @executable_path/../Frameworks/libABC.dylib
> libABC.dylib
> $ install_name_tool -id @executable_path/../Frameworks/libXYZ.dylib
> libXYZ.dylib
>
> This changes the inside dylib paths as
> $ otool -L libABC.dylib
> libABC.dylib:
> @executable_path/../Frameworks/libABC.dylib (compatibility version
> 1.0.0, current version 1.0.0)
> libXYZ.dylib (compatibility version 0.0.0, current version 0.0.0)
> /usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version
> 111.1.5)
>
> $ otool -L libXYZ.dylib
> libXYZ.dylib:
> @executable_path/../Frameworks/libXYZ.dylib (compatibility version
> 0.0.0, current version 0.0.0)
> /usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version
> 111.1.5)
>
>
> The problem here is:
> libABC is internally calling libXYZ,
> i am unable to change this path, to a path relative to my mach-o binary
> (inside my app bundle)
Sure, you are able to change that path.
$ install_name_tool -change libXYZ.dylib @executable_path/../Frameworks/libXYZ.dylib libABC.dylib
By the way, there's no point in changing the install name (using the -id option) as you have, above, if you do it after linking.
The install name of a dynamic library is used by the linker to create the reference to the library in whatever depends on it. It is not used at load time. Only the references from one Mach-O binary to its dependencies are used at load time, so that's what you need to change.
If you change the install names _before_ linking, then the references will be correct from the start and then you won't have to change them after the fact.
> So my app is failing to load.
>
> Dyld Error Message:
> Library not loaded: libXYZ.dylib
> Referenced from:
> /Users/pd/Desktop/MyTool.app/Contents/MacOS/../Frameworks/libABC.dylib
> Reason: image not found
Regards,
Ken
_______________________________________________
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