Skip navigation.
 
mlRe: Getting a bundle to load symbols from the main app bundle
FROM : Michael Ash
DATE : Sat Jul 08 17:53:33 2006

On 7/7/06, Damien Sorresso <<email_removed>> 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.

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.

Mike

Related mailsAuthorDate
mlGetting a bundle to load symbols from the main app bundle Damien Sorresso Jul 8, 04:24
mlRe: Getting a bundle to load symbols from the main app bundle Michael Ash Jul 8, 17:53
mlRe: Getting a bundle to load symbols from the main app bundle Damien Sorresso Jul 10, 20:11