文本输入源服务为架构x86_64提供了Mach-O链接器错误?

时间:2011-09-12 01:01:14

标签: objective-c macos

我正在尝试使用文本输入源服务来检测当前的键盘布局:

TISInputSourceRef source = TISCopyCurrentKeyboardInputSource(); //Mach-O Linker Error
NSLog(@"languages: %@", TISGetInputSourceProperty(source, kTISPropertyInputSourceLanguages));
NSLog(@"localized name: %@", TISGetInputSourceProperty(source, kTISPropertyLocalizedName));

我参考的是('现代')碳函数:#import <Carbon/Carbon.h>

文档:(不要提及有关x86与x64的任何内容) http://developer.apple.com/library/mac/#documentation/TextFonts/Reference/TextInputSourcesReference/Reference/reference.html

Undefined symbols for architecture x86_64:
  "_TISCopyCurrentKeyboardInputSource", referenced from:
      -[XXXFILE YYYEVENT:] in ZZZPROJECT.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)

是否有理由不能将TIS与x86_64编译器一起使用?

1 个答案:

答案 0 :(得分:1)

感谢Bavarious对这个问题的评论,添加了Carbon.framework,而不仅仅是#include。回答一个真实的Stack Overflow Answer,我会赞成它!