Reputation: 753
I have some C++ source files (with .mm extension) in an XCode project. I'm trying to compile only those that are pure C++ (no objc syntax or cocoa runtime used) and compile them in an Android NDK build (NDK r8d). The problem seems to be that g++ will not even consider .mm files as C++ and will fail with:
arm-linux-androideabi-g++: error: Objective-C++ compiler not installed on this system
I tried:
1. LOCAL_CPP_EXTENSION := .mm (in Android.mk) - doesn't help.
2. Search g++ documentation on how to accept custom file extensions - couldn't find any.
I'd really like to find a way to force NDK/g++ to accept .mm files, but open to other ideas like:
Does anyone have some experience or ideas on this? Thanks.
Solution (see accepted answer)
LOCAL_CFLAGS += -x c++
Upvotes: 2
Views: 2618
Reputation: 61396
Despite the accepted answer, I'd still say that renaming the files to .CPP would be the right thing to do. What's so controversial about making the extension match the content? Xcode would be fine with compiling C++ files, and as a bonus, it'll protect you from accidentally polluting it with Objective C++ on the iOS side.
Upvotes: 1
Reputation: 14467
Add the "-x c++" option to $CFLAGS variable in .mk file. This should force GCC to use the C++ compiler.
EDIT: sorry for the typo, "-x" option, not "-c" and "c++", not "cpp"
Upvotes: 2