Hi Jens,

Thanks for your patience.   I'm getting a better understanding.   Also, it 
helped a bit reading through ...

http://developer.apple.com/library/mac/#documentation/developertools/conceptual/MachOTopics
and
http://developer.apple.com/library/mac/#documentation/DeveloperTools/Conceptual/DynamicLibraries

However, I'm still not sure what is the right way to do this.   I have made the 
pointer global (no long declared as "static"),...

CFMutableSetRef unitsLibrary = NULL;

in my "Units" static library.   The main app begins using the "Units" library 
at startup and starts filling this set.   Then, eventually the plugin gets 
loaded. In the plugin factory function I added ...

    CFBundleRef bundle = CFBundleGetMainBundle();
    CFMutableSetRef *pointer =  CFBundleGetDataPointerForName 
(bundle,CFSTR("unitsLibrary"));
    PSUnitSetLibrary(*pointer);

and this works!   The plugin now "knows" about all the previous units that were 
defined in the main app.

But I'm troubled by this solution.   If I set debugger break points in the 
"Units" library the debugger no longer stops at those breakpoints when called 
by the plugin, but it does stop at those breakpoints when called by the main 
app.   Makes me think I have two copies of code for my static units library 
running after the plugin is loaded.   Does that make sense?

Philip




On Jan 2, 2012, at 1:22 PM, Jens Alfke wrote:

> 
> On Jan 2, 2012, at 7:52 AM, Grandinetti Philip wrote:
> 
>> You raise a fundamental issue that I admit I don't completely understand.   
>> What are the differences between linking against a static library versus a 
>> framework.   If I turned all my static libraries into a framework would the 
>> plugin see the static variables in the framework without having to do all 
>> the Xcode linking magic?
> 
> The difference is copying vs. referencing. A static library gets copied into 
> the target at link time, whereas if you link with a dynamic library or 
> framework, the linker just notes down what symbols are referenced, and at 
> load time those get resolved to those symbols in the library.
> 
> For your purposes, the difference is that in a static library, everything 
> that links with it has its own private copy of the library's global 
> variables. In a dylib/framework, everything that links with it shares its 
> global variables. The latter is what you want.
> 
> —Jens
> 

_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to