开发者

Why on Mac, NSReadPixel() will cause "_NSReadPixel", referenced from: _main in cctJJibI.o ld: symbol(s) not found?

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
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜