Forum Discussion

🚨 This forum is archived and read-only. To submit a forum post, please visit our new Developer Forum. 🚨
ejonathanlindgr's avatar
7 years ago

How to make VrCubeWorld_NativeACtivity examples run as C++ code instead of C code

I am exploring the VrCubeWorld_NativeActivity example in VrSamples of the Mobile SDK. I can successfully compile and run it on my oculus go using Android Studio. I would now like to start with that source code and modify it for my own project as a starting point as I am quite new to android/VR development.

However, I would like to use C++ instead of C, but I am not able to compile the project as a C++ project. Renaming the file to a .cpp file and adding
LOCAL_CPPFLAGS          := -std=c++11

in Android.mk, does not work, Android Studio build fails with an org.gradle.api.ProjectConfigurationException: A problem occurred configuring project ':MyProjects:Test:Projects:Android'. exception.

Is there a quick way to modify the VrCubeWorld_* examples in VrSamples so they compile as C++ code instead of C code? How should I modify the gradle files and .mk files? I am very new to gradle etc so that is still magic to me.

2 Replies

  • @imperativity do you have any insight into this problem, or where to find help about it?
  • I managed to make it work, by having minimal C code as entry point for the native application, and then calling a C++ code from the C code where I moved the VrCubeWorld source code, with some minor changes to the source code such that it is valid C++. If anyone is interested I could write up how to do it