Skip navigation.
 
mlCarbon-Cocoa Integration: Linking issue
FROM : Aaron Vegh
DATE : Tue Jan 22 03:48:43 2008

Hello all,
I've run into an intractable problem trying to integrate code from my
Cocoa app into a separate build in the same project, which is a
Carbon-based Contextual Menu Item (CMI) Plugin. I've been following
the document outlined in the Carbon/Cocoa Integration Guide, but it
doesn't seem to be of any help. Here's what I'm trying to do:

I have a single project with a main Cocoa app build, and a Carbon CMI
build (dammit for there not being a Cocoa interface to CMI!!!). The
Cocoa app works quite well, thank you, and the templated parts of the
CMI code (as gleaned from the Apple dev site) appear to be functioning
fine. I have that Carbon code snagging the file path from the selected
item in the Finder, and using Cocoa, outputting that path to NSLog().
W00t! The steps are:

1. Create MyAppPlugin.m (so it's compiled as Obj-C).
2. Include <Cocoa/Cocoa.h> at the top of this file.
3. In the mostly-Carbon file, create a C-callable wrapper function for
the Obj-C functionality.
4. In said function, I can get my file path from the Carbon handler,
and I can shovel it into NSLog().
5. However, when I make a call to my own class in the Cocoa app, I get
the following error:

ld: duplicate symbol .objc_class_name_MyController in
/Users/aaron/Developer/MyApp/build/MyApp.build/Release/MyAppPlugin.build/Objects-normal/ppc/MyAppPlugin.o
and /Users/aaron/Developer/MyApp/build/MyApp.build/Release/MyAppPlugin.build/Objects-normal/ppc/MyController.o

In XCode, I've included MyController.m in the Build target (all kinds
of errors result otherwise). The Cocoa function is pretty simple:

void sendPathToMyApp (char *path) {
   NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
   NSString *thePath = [NSString stringWithCString:path
                               encoding:NSUTF8StringEncoding];
   MyController *newMyController = [[MyController alloc] init];
   NSLog(@"Handed the path %@", thePath);
   [newMyController showWindow:nil];
   [newMyController setThePath:thePath];
   [pool release];
} /*sendPathToMyApp*/

Except for the initial call to #include "MyController.m" at the top of
the file, what you see here are the only instances of MyController in
the file. How is it that there could be duplicate symbols? And why do
system calls to the Cocoa library work okay (comment out all my
controller calls, and NSLog DOES return the correct data), but not my
own?

I feel like I've tried everything, so my app has been at a stand-still
for two weeks! Anyone who could suggest a solution would find me
extremely grateful... :-)

Cheers,
Aaron.

--
Aaron Vegh, Principal
Innoveghtive Inc.
P: (647) 477-2690
C: (905) 924-1220
www.innoveghtive.com
www.website-in-a-day.com

Related mailsAuthorDate
mlCarbon-Cocoa Integration: Linking issue Aaron Vegh Jan 22, 03:48
mlRe: Carbon-Cocoa Integration: Linking issue Kyle Sluder Jan 22, 04:00
mlRe: Carbon-Cocoa Integration: Linking issue Shripada Hebbar Jan 22, 05:09
mlRe: Carbon-Cocoa Integration: Linking issue Aaron Vegh Jan 22, 05:23
mlRe: Carbon-Cocoa Integration: Linking issue Shripada Hebbar Jan 22, 05:40
mlRe: Carbon-Cocoa Integration: Linking issue Aaron Vegh Jan 22, 13:20
mlRe: Carbon-Cocoa Integration: Linking issue Eric Schlegel Jan 22, 18:39
mlRe: Carbon-Cocoa Integration: Linking issue Aaron Vegh Jan 22, 20:48