[SOLVED] Build 1.9 for Android - cpu-features.h missing

Problems building or running the engine, queries about how to use features etc.
Post Reply
Seranth
Gnoblar
Posts: 15
Joined: Mon Jul 11, 2016 1:50 am
x 1

[SOLVED] Build 1.9 for Android - cpu-features.h missing

Post by Seranth »

I'm trying to build Ogre3D for Android.

I've tried changing #include <cpu-features.h> to #include <machine/cpu-features.h> and that leads to another set of issues.

Currently trying to build version 1.9

If I change to #include <machine/cpu-features.h> in OgrePlatformInformation.cpp:

Code: Select all

/home/simon/Downloads/ogre/OgreMain/src/OgrePlatformInformation.cpp: In function 'Ogre::uint Ogre::_detectCpuFeatures()':
/home/simon/Downloads/ogre/OgreMain/src/OgrePlatformInformation.cpp:482:55: error: 'android_getCpuFeatures' was not declared in this scope
         uint64_t cpufeatures = android_getCpuFeatures();
                                                       ^
/home/simon/Downloads/ogre/OgreMain/src/OgrePlatformInformation.cpp:484:27: error: 'ANDROID_CPU_ARM_FEATURE_NEON' was not declared in this scope
         if (cpufeatures & ANDROID_CPU_ARM_FEATURE_NEON) 
                           ^
/home/simon/Downloads/ogre/OgreMain/src/OgrePlatformInformation.cpp:489:27: error: 'ANDROID_CPU_ARM_FEATURE_VFPv3' was not declared in this scope
         if (cpufeatures & ANDROID_CPU_ARM_FEATURE_VFPv3) 
                           ^
/home/simon/Downloads/ogre/OgreMain/src/OgrePlatformInformation.cpp: In function 'Ogre::String Ogre::_detectCpuIdentifier()':
/home/simon/Downloads/ogre/OgreMain/src/OgrePlatformInformation.cpp:499:9: error: 'AndroidCpuFamily' was not declared in this scope
         AndroidCpuFamily cpuInfo = android_getCpuFamily();
         ^
/home/simon/Downloads/ogre/OgreMain/src/OgrePlatformInformation.cpp:501:17: error: 'cpuInfo' was not declared in this scope
         switch (cpuInfo) {
                 ^
/home/simon/Downloads/ogre/OgreMain/src/OgrePlatformInformation.cpp:502:18: error: 'ANDROID_CPU_FAMILY_ARM' was not declared in this scope
             case ANDROID_CPU_FAMILY_ARM:
                  ^
/home/simon/Downloads/ogre/OgreMain/src/OgrePlatformInformation.cpp:504:44: error: 'android_getCpuFeatures' was not declared in this scope
                 if (android_getCpuFeatures() & ANDROID_CPU_ARM_FEATURE_ARMv7) 
                                            ^
/home/simon/Downloads/ogre/OgreMain/src/OgrePlatformInformation.cpp:504:48: error: 'ANDROID_CPU_ARM_FEATURE_ARMv7' was not declared in this scope
                 if (android_getCpuFeatures() & ANDROID_CPU_ARM_FEATURE_ARMv7) 
                                                ^
/home/simon/Downloads/ogre/OgreMain/src/OgrePlatformInformation.cpp:514:18: error: 'ANDROID_CPU_FAMILY_X86' was not declared in this scope
             case ANDROID_CPU_FAMILY_X86:
                  ^
make[2]: *** [OgreMain/CMakeFiles/OgreMain.dir/src/OgrePlatformInformation.cpp.o] Error 1
make[1]: *** [OgreMain/CMakeFiles/OgreMain.dir/all] Error 2
make: *** [all] Error 2
I've tried building with 1.9, 1.10, 2.0, 2.1 and this is as far as I get.
Last edited by Seranth on Thu Oct 06, 2016 7:14 am, edited 2 times in total.
User avatar
dark_sylinc
OGRE Team Member
OGRE Team Member
Posts: 5296
Joined: Sat Jul 21, 2007 4:55 pm
Location: Buenos Aires, Argentina
x 1278
Contact:

Re: Build for Android - cpu-features.h missing

Post by dark_sylinc »

NDK stikes again. Google keeps changing vital components of the NDK breaking builds over and over again. We just can't keep up.

If you can figure out what's the new way (probably they renamed seven bits here and there, or moved things to a different header), then fix it and tell us the solution :)

Otherwise try grabbing an older version of the NDK.
Seranth
Gnoblar
Posts: 15
Joined: Mon Jul 11, 2016 1:50 am
x 1

Re: Build for Android - cpu-features.h missing

Post by Seranth »

I solved it :D

You can solve this by adding this line to CMakeLists.txt in Ogre3D: include_directories(/opt/android-ndk/sources/android/cpufeatures)

Of course, replace it with the correct path to your NDK.

If you get errors related to C++11, you can also add this to fix it: set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++98")

It doesn't matter where you place them, but you might as well place them just after the CMake version settings, that way you can be sure they're applied where necessary.

Code: Select all

if(ANDROID)
  set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++98")
  include_directories(/opt/android-ndk/sources/android/cpufeatures)
endif(ANDROID)
Additionally you might have problems with something that has to do with NativeWindow. In the Ogre3D sources, go to RenderSystems/GLES2/include/EGL/Android/OgreAndroidEGLWindow.h and add #include "android/native_window.h"

Code: Select all

...
#include "OgreEGLWindow.h"
#include "OgreAndroidEGLSupport.h"
#include "android/configuration.h"
#include "android/native_window.h" // <- This
...
Lastly, if the samples fail to build, just disable them because lets face it you're a baws at Ogre3D and you don't need them.

If you have problems with OgreJNIDummy, I couldn't find an existing option to disable it, but you can just go to the CMakeLists.txt and comment out the line include(toolchain/AndroidJNI) at around line 523.

Code: Select all

if(ANDROID)
# include(toolchain/AndroidJNI)
endif(ANDROID)
Post Reply