• 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
Linking C++ and Objective-C files
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Linking C++ and Objective-C files


  • Subject: Linking C++ and Objective-C files
  • From: Andreas Menzi <email@hidden>
  • Date: Fri, 24 Jul 2009 09:58:30 +0200

Hi all,

I have a problem linking an m-file in my project which is a C++ bundle. I tried to include the m-file from the following code sample in my project:
http://developer.apple.com/samplecode/CarbonCocoa_PictureCursor/  the code is the following:

// From "Cocoa Drawing Guide: Working with Images"
NSImage *CreateNSImageFromCGImage( CGImageRef image )
{
NSRect imageRect = NSMakeRect(0.0, 0.0, 0.0, 0.0);

// Get the image dimensions.
imageRect.size.height = CGImageGetHeight(image);
imageRect.size.width = CGImageGetWidth(image);

// Create a new image to receive the Quartz image data.
NSImage *newImage = [[NSImage alloc] initWithSize:imageRect.size]; 
[newImage lockFocus];

// Get the Quartz context and draw.
CGContextRef imageContext = (CGContextRef) [[NSGraphicsContext currentContext] graphicsPort];
CGContextDrawImage( imageContext, *(CGRect*)&imageRect, image );
[newImage unlockFocus];

return( newImage );
}

// C-based style wrapper routines around NSCursor
CursorRef CreateCocoaCursor( CGImageRef cgImageRef, float hotSpotX, float hotSpotY )
{
static BOOL firstTime = YES;

if ( firstTime )
{
// Must first call [[[NSWindow alloc] init] release] to get the NSWindow machinery set up so that NSCursor can use a window to cache the cursor image
[[[NSWindow alloc] init] release];
firstTime = NO;
}

NSImage *nsImage = CreateNSImageFromCGImage( cgImageRef );
NSCursor *cursor = [[NSCursor alloc] initWithImage:nsImage hotSpot:NSMakePoint( hotSpotX, hotSpotY )];

[nsImage release];

return( (CursorRef)cursor );
}

When trying to build my bundle, I get the following error:

Undefined symbols:
  "CreateCocoaCursor(CGImage*, float, float)", referenced from:
      PT_AreaSetup(PluginBlock*)      in PlotToolFunc.o
ld: symbol(s) not found

Does anyone have an idea what I'm doing wrong? It seems like the m-file isn't compiled but I don't know why.

andy


D
 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Xcode-users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

  • Follow-Ups:
    • Re: Linking C++ and Objective-C files
      • From: Thierry Faucounau <email@hidden>
    • Re: Linking C++ and Objective-C files
      • From: Jens Ayton <email@hidden>
    • Re: Linking C++ and Objective-C files
      • From: Philip Aker <email@hidden>
  • Prev by Date: Re: How to create dependent projects?
  • Next by Date: Re: Linking C++ and Objective-C files
  • Previous by thread: Re: Trouble with Xcode and gcc
  • Next by thread: Re: Linking C++ and Objective-C files
  • Index(es):
    • Date
    • Thread