我在我的Objective-C应用中使用Xcode 6.1。
我的应用程序使用GameKit框架。
我试图从我的GameViewController(Objective-C源文件)调用外部C ++方法。
为了使GameViewController.mm编译,我不得不手动将类型设置为“Objective-C ++源”。
然而,即使现在该源代码可以编译,它也会在链接时失败,并显示以下错误:
Undefined symbols for architecture x86_64:
"_OBJC_CLASS_$_GLKViewController", referenced from:
_OBJC_CLASS_$_GameViewController in GameViewController.o
"_OBJC_METACLASS_$_GLKViewController", referenced from:
_OBJC_METACLASS_$_GameViewController in GameViewController.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
只有将类型设置为"Objective-C Source"并删除对外部C++函数的调用,才能消除链接器错误。
如果我的源文件编译为"Objective-C++ Source"而不是"Objective-C Source"类型,为什么链接器会失败?
请注意,我在Build-phases正确地链接了GameKit。