我试图用XCode编译一个简单的命令行工具:
#import <Cocoa/Cocoa.h>
int main (int argc, const char * argv[]) {
NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
//NSSpeechSynthesizer *speeker = [[NSSpeechSynthesizer alloc] initWithVoice: nil];
NSLog(@"%@", [NSSpeechSynthesizer availableVoices]);
NSLog(@"Hello, World!");
[pool drain];
return 0;
}
即使我是在进口Cocoa.h,我也得到了一个链接错误:
未定义符号:
"_OBJC_CLASS_$_NSSpeechSynthesizer",引用于: objc-class-ref-to-NSSpeechSynthesizer in byc.o :符号not collect2: ld返回1退出状态。
有人知道这是怎么回事吗?
发布于 2010-11-05 10:08:24
您导入了标头,所以编译成功了,但是链接失败了,因为您没有针对提供NSSpeechSynthesizer的框架进行链接。您需要链接到Application框架(除了Foundation)或Cocoa伞式框架(而不是Foundation)。
无论您选择哪种框架,都可以将其添加到项目组树中的链接框架组中(右击组并选择“添加现有框架”),并确保将其添加到目标中。
https://stackoverflow.com/questions/4108719
复制