1

I'm having problems with the use of the class NSImage. I'm trying to use the function initWithData: but it does not work (anything related to NSImage doesn't work). Here is a simple example of what im trying. The NSData data is right.

My project is a commandline tool of foundation type.

NSData *imdata =[[NSData alloc] initWithContentsOfFile:@"/Users/JulianDavid/Desktop/ecoli_20000.png"];
if(!imdata){
    NSLog(@"there is data");
}
NSImage *imag=[[NSImage alloc]initWithData:imdata];
dandan78
  • 13,328
  • 13
  • 64
  • 78
  • Is the file being loaded successfully? – Adam Rosenfield Oct 03 '12 at 18:20
  • Undefined symbols for architecture x86_64: "_OBJC_CLASS_$_NSImage", referenced from: objc-class-ref in main.o ld: symbol(s) not found for architecture x86_64 clang: error: linker command failed with exit code 1 (use -v to see invocation)......... The Data is being loaded succesfully to NSData. but the data isnt being loaded to NSImage. – Julian David Arroyo Orejuela Oct 03 '12 at 22:04
  • 1
    @Julian: Don't add crucial information in comments. Edit your question instead, and add the information there where people can see it when they first read your question. – Ken White Oct 04 '12 at 17:30

1 Answers1

4

The error

Undefined symbols for architecture x86_64: "_OBJC_CLASS_$_NSImage"

means that the linker can't find the code implementing the NSImage class. According to the NSImage documentation, it's implemented in the AppKit framework. So, in order for the linker to link the code properly, you need to link against the AppKit framework. Do this by adding the AppKit framework into your Xcode project.

Community
  • 1
  • 1
Adam Rosenfield
  • 390,455
  • 97
  • 512
  • 589