Changing the source file type to Objective-C ++ causes a linker error when using GameKit

So, I am using Xcode 6.1 in my Objective-C application. My application uses the GameKit framework.

I tried calling external C ++ methods from my GameViewController (which is the Objective-C source.)

In order to compile GameViewController.mm, I had to set the type 'Objective-C ++ Source' manually.

However, even if the source code is now compiled, it will not be able to reference:

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) 

I can get rid of the linker error by setting the type back to 'Objective-C Source' and removing calls to external C ++ functions.

Why does the linker not work if my source is compiled as 'Objective-C ++ Source' instead of 'Objective-C Source' type?

Please note that I am correctly attached to GameKit at the build stages.

+5
source share
1 answer

OK This turns out to be strange, but:

I contacted GameKit, not GLKit. Fix: link to GLKit as well.

Now the weird part is that not binding GLKit does not cause problems if the view controller is built as an Objective-C source. This causes problems when building as an Objective-C ++ source.

Strange, but true.

+3
source

Source: https://habr.com/ru/post/1207705/


All Articles