On Mac OS X Snow Leopard, the program uses:
#import <Foundation/Foundation.h>
#import <ApplicationServices/ApplicationServices.h>
#import <AppKit/AppKit.h>
CGPoint pt;
pt.x = x;
pt.y = y;
NSColor* color = NSReadPixel(pt);
but during compilation, it will say:
"_NSReadPixel", referenced from:
_main in cctJJibI.o
ld: symbol(s) not found
the co开发者_开发百科mpilation line is
gcc -o trytry trytry.m -framework ApplicationServices -framework Foundation
gcc's version is gcc version 4.2.1 (Apple Inc. build 5666) (dot 3)
the answer is, it needs the AppKit on the compile line as well:
gcc -o trytry trytry.m -framework ApplicationServices -framework Foundation
-framework AppKit
精彩评论