• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Getting a bundle to load symbols from the main app bundle
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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

  • Prev by Date: Re: Out-of-order Undos and NSTextField
  • Next by Date: NSPopupButtonCell in NSTableView
  • Previous by thread: Re: Getting a bundle to load symbols from the main app bundle
  • Next by thread: iPhoto integration?
  • Index(es):
    • Date
    • Thread