Re: Getting a bundle to load symbols from the main app bundle
Re: Getting a bundle to load symbols from the main app bundle
- Subject: Re: Getting a bundle to load symbols from the main app bundle
- From: Damien Sorresso <email@hidden>
- Date: Mon, 10 Jul 2006 13:11:49 -0500
On 8 Jul, 2006, at 10:53 AM, Michael Ash wrote:
On 7/7/06, Damien Sorresso <email@hidden> wrote:
I've got a program that dynamically loads bundles, and I'd like those
bundles to load a symbol from the main application bundle.
Specifically, I'd like them to get a hold of the value of a global
debug variable.
I'm currently doing this from the loadable bundle.
__debug_level = (int *)CFBundleGetDataPointerForName(mainBundle,
CFSTR
("__debug_level"));
But `CFBundleGetDataPointerForName()' returns NULL in this case. When
I do this call from the main application bundle, I get garbage. So
I'm wondering if my main app's symbols aren't getting exported
properly.
If "__debug_level" is the actual variable name then the symbol name
will have an extra underscore prepended and so should be
"___debug_level". Otherwise if the name is actually "_debug_level"
then it sounds like it's not getting exported properly. You could
check using /usr/bin/nm which will save you from speculating.
I've verified that the symbol is being exported correctly. The CF
calls just don't want to grab it. Would it be because the main bundle
is an executable and not dynamically loadable?
Once you get the symbol to export properly, or verify that it is
exported properly already, you can bypass the whole manual symbol
lookup by setting your bundle's Bundle Loader. This will effectively
link the bundle against your application, allowing you to refer to
__debug_level directly using an extern, as well as access any other
symbols the application provides in a simpler fashion.
I'm trying that, but `ld' keeps coming back saying that the
executable cannot be found. I'm pretty sure it's because the main
executable gets built after the bundle. Is there any way I can tell
the target to link against the executable at the very end rather than
immediately after the object code is generated?
--
Damien Sorresso
Macintosh Developer
Computer Infrastructure Support Services
Illinois State University
email@hidden
Attachment:
smime.p7s
Description: S/MIME cryptographic signature
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden