Re: can't open dynamic library
Re: can't open dynamic library
- Subject: Re: can't open dynamic library
- From: Steve Christensen <email@hidden>
- Date: Fri, 27 Jun 2008 22:02:56 -0700
On Jun 27, 2008, at 2:32 PM, Dan Korn wrote:
I'm building a plug-in bundle (A), which links to a dynamic library
(B), which in turn links to another dynamic library (C). All the
libraries are intended to be included in the plug-in's bundle. The
first dynamic library (B) links just fine, but when I try to link
the main plug-in (A), I get a "can't open dynamic library" warning
about the second dynamic library (C), and none of the symbols in
the first dynamic library (B) are found, so the link fails.
I'm not sure I understand the philosophy behind this. The library
(B) to which I'm trying to link is fully built. I can understand
that at *run time* I need to have all the libraries in the right
places, but why does the entire dynamic loading tree have to be
satisfied at *link time*? All that the linker should care about,
as far as I know, is whether the library I'm linking to exports the
functions it needs, right?
Shouldn't the linker just link, and let the dynamic loader do its
thing at run time to make sure the dynamic libraries and their
functions are actually loaded?
"warning can't open dynamic library: @loader_path/
libwx_mac_u_d.dylib", which I have no idea how to resolve. What
does "@loader_path" resolve to while I'm linking?
"@loader_path" doesn't resolve to anything at link time. The linker
already knows where the library is at link time because you've
included it as part of your Xcode project. The important thing to
note is that the install name is only used at runtime to locate the
libraries in their installed locations. This should be clear in that
you typically link against frameworks in one of the SDK directories,
but at runtime your executable finds the ones in /System/Library/
Frameworks. The install name gets stuffed into your executable at
link time and used at runtime to locate the specific library so it
can resolve the symbols.
Using your library terminology from above, I believe your build
process should look like this:
1. Build dylib C.
2. Run install_name_tool to change C's install name to
@loader_path/../Frameworks/C.dylib.
3. Build dylib B, linking it against dylib C from step 2.
4. Run install_name_tool to change B's install name to
@loader_path/../Frameworks/B.dylib.
5. Build your plugin, linking it against dylib B from step 4.
6. Copy dylibs B and C to your bundle's Frameworks directory.
install_name_tool is being run when it is, above, because at runtime,
dylib B will need to find dylib C next to it in the Frameworks
directory inside the plug-in's bundle, so the install name for dylib
C has to be set before dylib B links against it. Same thing with the
plug-in and dylib B.
>otool -L fpunicodeui_macho_d.dylib
fpunicodeui_macho_d.dylib:
/usr/local/lib/fpunicodeui_macho_d.dylib (compatibility version
1.0.0, current version 1.0.0)
/System/Library/Frameworks/Carbon.framework/Versions/A/Carbon
(compatibility version 2.0.0, current version 128.0.0)
@executable_path/../Frameworks/JS.framework/Versions/A/JS
(compatibility version 1.0.0, current version 1.0.0)
/Library/Frameworks/libwx_mac_u_d.dylib (compatibility version
2.8.0, current version 2.8.6)
@executable_path/../Frameworks/WASTE.framework/Versions/A/WASTE
(compatibility version 1.0.0, current version 1.0.0)
/usr/lib/libstdc++.6.dylib (compatibility version 7.0.0, current
version 7.4.0)
/usr/lib/libgcc_s.1.dylib (compatibility version 1.0.0, current
version 1.0.0)
/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current
version 88.3.9)
JS.framework and WASTE.framework are listed as being relative to the
application (@executable_path). Is that right, or are they also being
included in your plug-in's bundle? If so, they may need to be fixed
up as well.
steve
Attachment:
PGP.sig
Description: PGP signature
_______________________________________________
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