gpt4 book ai didi

objective-c - 访问 NSSpeechSynthesizer 时出现链接错误

转载 作者:行者123 更新时间:2023-12-03 18:03:37 25 4
gpt4 key购买 nike

我正在尝试使用 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,但出现链接错误:

Undefined symbols:
"_OBJC_CLASS_$_NSSpeechSynthesizer", referenced from: objc-class-ref-to-NSSpeechSynthesizer in byc.o ld: symbol(s) not found collect2: ld returned 1 exit status

有人知道这是怎么回事吗???

最佳答案

您导入了 header ,因此编译工作正常,但链接失败,因为您没有链接到提供 NSSpeechSynthesizer 的框架。您需要链接到 Application Kit 框架(除了 Foundation 之外)或 Cocoa 伞形框架(而不是 Foundation)。

无论您选择哪个框架,都请将其添加到项目组树中的链接框架组中(右键单击该组并选择“添加现有框架”),并确保也将其添加到您的目标中。

关于objective-c - 访问 NSSpeechSynthesizer 时出现链接错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4108719/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com