views:

51

answers:

1

I am working on an extension to Vienna to add the ability for third parties to write Objective-C plugins, but I am getting some runtime linker issues only when running in 64-bit mode (everything appears to work fine in 32-bit mode). My plugin, SynkPlugin, is loaded by the following code in Vienna.app:

NSArray * bundlePaths = [NSBundle pathsForResourcesOfType:@"bundle" inDirectory:[[Preferences standardPreferences] pluginsFolder]];
NSEnumerator * enumerator = [bundlePaths objectEnumerator];
NSString * bundlePath;
NSMutableArray * plugins = [NSMutableArray array];
while ( (bundlePath = [enumerator nextObject]) != nil )
{
    NSBundle * pluginBundle = [NSBundle bundleWithPath:bundlePath];
    Class principalClass = [pluginBundle principalClass];
    id <ViennaPlugin, NSObject> plugin = [[principalClass alloc] init];
    [plugins addObject:plugin];
    [plugin release];
    NSLog(@"Loaded plugin %@ [main class: %@]", bundlePath, principalClass);
}

And in the console output, I get the following error message:

2010-07-09 08:55:40.128 Vienna[74065:a0f] Error loading /Users/dcrosta/Library/Application Support/Vienna/PlugIns/SynkPlugin.bundle/Contents/MacOS/SynkPlugin: dlopen(/Users/dcrosta/Library/Application Support/Vienna/PlugIns/SynkPlugin.bundle/Contents/MacOS/SynkPlugin, 265): Symbol not found: _OBJC_CLASS_$_Article
  Referenced from: /Users/dcrosta/Library/Application Support/Vienna/PlugIns/SynkPlugin.bundle/Contents/MacOS/SynkPlugin
  Expected in: flat namespace
  in /Users/dcrosta/Library/Application Support/Vienna/PlugIns/SynkPlugin.bundle/Contents/MacOS/SynkPlugin

This error only happens when running in 64-bit mode, not 32-bit mode. Both Vienna and SynkPlugin are compiled with the "standard 32/64 universal" settings, and SynkPlugin has the additional linker flag "-undefined dynamic_lookup", which, it is my understanding, allows it to link to classes found in Vienna.app without having to compile code for those classes into its own binary.

The other references to this error on Stack Overflow have to do with UIKit differences between iPhone/iPod Touch and iPad -- in those cases, the frameworks are actually missing the classes on iPhone/iPod Touch. In my case, I'm certain that Vienna.app has the Article class within it somewhere, since it is built from identical code to the 32-bit version.

Has anyone seen an error like this before? Have any suggestions on where to look for more information? Thanks.

+1  A: 

In the build settings of the Vienna target, under GCC 4.2 - Code Generation uncheck Symbols Hidden by Default (GCC_SYMBOLS_PRIVATE_EXTERN).

0xced
Sweet, thanks! Any idea why this worked in 32-bit builds (or when run as a 32-bit application in a universal build) but not 64-bit?
dcrosta
Yes, Symbol Visibility and Objective-C: http://developer.apple.com/mac/library/documentation/DeveloperTools/Conceptual/CppRuntimeEnv/Articles/SymbolVisibility.html#//apple_ref/doc/uid/TP40001670-98931
0xced
Note for reference: the target must also not have the "Strip Linked Product" option selected (under Deployment in build settings)
dcrosta