Seranth wrote:This part basically says that what it's not finding is the libPlugin_OctreeSceneManagerStatic.a file, which indeed does not exist anywhere. I tried manually altering the generated makefiles in the hopes OctreeSceneManager simply isn't needed but alas it seems to be a core part of Ogre (as far as I can tell anyway, which begs the question why it's called a plugin...).
As far as I can tell, when building for Android the OctreeSceneManager is never made. I've scoured CMake GUI and can't find any mentions of *Octree*. I can build "normal" Ogre3D without any issues. If you ask me the problem is that someone has forgotten to add Octree as a part of what's made when building for Android. Or perhaps Octree is not yet available to Android, which would explain why it can't be built for Android but begs the question why someone used it in the JNI samples.
Plugins like OctreeSceneManager, OctreeZone, PCZSceneManager are not build for 2.0/2.1 version - it seems that not all cmake files and configs were updated.
I will try to show here all the steps that I took to finally build Ogre 2.0 (v2-0 branch) for Android along with SampleBrowser/JNI applications. Let me just mention that both application do not work in the end (they run on the device but show only blank screen).
Steps for buildiding Ogre3D 2.0 for Android (API 10) - using Arch Linux 64bit, Android NDK R11C, cmake 3.5.2.
FIRST STEP:
Build OgreDependencies repository for Android (latest, default branch for mercurial repo).
Code: Select all
cmake -DCMAKE_INSTALL_PREFIX=/home/user/Downloads/Repositories.Develop/OgreDependencies/build-android-release -DCMAKE_BUILD_TYPE=Release -G"Unix Makefiles" -DCMAKE_TOOLCHAIN_FILE="../cmake/android.toolchain.cmake" -DANDROID_ABI=armeabi-v7a -DANDROID_NATIVE_API_LEVEL=10 -DANDROID_TOOLCHAIN_NAME=arm-linux-androideabi-4.9 ..
OgreDependencies will also be installed in the same build folder, instead of default '/opt/android-ndk/toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64/user' folder. (There is no make uninstall option so it is easier to mantain this way)
SECOND STEP:
Install OgreDependencies into the current build folder.
make install (or sudo make install, but sudo should not be necessary)
THIRD STEP:
Configure Ogre 2.0 build for Android (using
build-android-release as build directory):
Code: Select all
cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=/home/user/Downloads/Repositories.Develop/ogre3d-2.0-repo/build-android-release -DCMAKE_TOOLCHAIN_FILE="../CMake/toolchain/android.toolchain.cmake" -DOGRE_DEPENDENCIES_DIR=/home/user/Downloads/Repositories.Develop/OgreDependencies/build-android-release -DANDROID_ABI=armeabi-v7a -DANDROID_NATIVE_API_LEVEL=10 -DANDROID_TOOLCHAIN_NAME=arm-linux-androideabi-4.9 -DANDROID_GLES_ONLY=NO -DOGRE_BUILD_RENDERSYSTEM_GLES2=YES -DOGRE_SIMD_NEON=NO -DOGRE_SIMD_SSE2=NO -DANDROID_TOOLCHAIN_MACHINE_NAME=arm-linux-androideabi ..
This should successfully configure and find all dependencies as well:
Code: Select all
-----------------------------------------------------------------------------
-- The following external packages were located on your system.
-- This installation will have the extra features provided by these packages.
+ zlib
+ zziplib
+ freeimage
+ freetype
+ OpenGL ES 1.x
+ OpenGL ES 2.x
+ OpenGL ES 3.x
+ OIS
----------------------------------------------------------------------------
FEATURE SUMMARY
----------------------------------------------------------------------------
Building components:
+ Paging
+ MeshLodGenerator
+ Terrain
+ RTShader System
+ RTShader System Core Shaders
+ RTShader System Extensions Shaders
+ Volume
+ Overlay
Building plugins:
+ Particle FX
Building rendersystems:
+ OpenGL ES 2.x
Building executables:
+ Samples
Building core features:
+ Mesh Lod
+ DDS image codec
+ PVRTC image codec
+ ETC image codec
+ FreeImage codec
+ ZIP archives
Build type: static
Threading support: none
Use double precision: disabled
Assert mode: standard
Allocator type: nedmalloc (pooling)
STL containers use allocator: enabled
Strings use allocator: disabled
Memory tracker (debug): disabled
Memory tracker (release): disabled
Use 1.x legacy animations: enabled
Use Boost: disabled
Use SIMD (SSE2): disabled
Use SIMD (NEON): disabled
FOURTH STEP:
First run: make -j2 - build Ogre 2.0
FIRST ERROR:
Code: Select all
ogre3d-2.0-repo/OgreMain/src/OgrePlatformInformation.cpp:41:28: fatal error: sys/sysctl.h: No such file or directory
#include <sys/sysctl.h>
^
compilation terminated.
FIX (thanks @bbm / @Seranth):
Code: Select all
diff -r 8323e2268f11 OgreMain/src/OgrePlatformInformation.cpp
--- a/OgreMain/src/OgrePlatformInformation.cpp Wed Jun 22 09:07:58 2016 +0200
+++ b/OgreMain/src/OgrePlatformInformation.cpp Wed Jul 20 09:31:30 2016 +0200
@@ -37,7 +37,7 @@
#elif (OGRE_COMPILER == OGRE_COMPILER_GNUC || OGRE_COMPILER == OGRE_COMPILER_CLANG) && OGRE_PLATFORM != OGRE_PLATFORM_NACL
#include <signal.h>
#include <setjmp.h>
-#if OGRE_PLATFORM != OGRE_PLATFORM_WIN32
+#if OGRE_PLATFORM != OGRE_PLATFORM_WIN32 && OGRE_PLATFORM != OGRE_PLATFORM_ANDROID
#include <sys/sysctl.h>
#endif
Second try:
make -j2
SECOND ERROR:
Code: Select all
[100%] Linking CXX shared module ../../lib/libSampleBrowserDummy.so
/opt/android-ndk/toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64/bin/../lib/gcc/arm-linux-androideabi/4.9/../../../../arm-linux-androideabi/bin/ld: fatal error: -soname: must take a non-empty argument
collect2: error: ld returned 1 exit status
make[2]: *** [Samples/Browser/CMakeFiles/SampleBrowserDummy.dir/build.make:95: lib/libSampleBrowserDummy.so] Error 1
make[1]: *** [CMakeFiles/Makefile2:3558: Samples/Browser/CMakeFiles/SampleBrowserDummy.dir/all] Error 2
make: *** [Makefile:150: all] Error 2
FIX:
Code: Select all
diff -r 8323e2268f11 Samples/Browser/CMakeLists.txt
--- a/Samples/Browser/CMakeLists.txt Wed Jun 22 09:07:58 2016 +0200
+++ b/Samples/Browser/CMakeLists.txt Wed Jul 20 09:43:53 2016 +0200
@@ -224,6 +224,9 @@
file(COPY "${CMAKE_SOURCE_DIR}/SDK/Android/drawable-xhdpi" DESTINATION "${NDKOUT}/res")
file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/dummy.cpp "int x = 0;")
+
+ string(REPLACE "<CMAKE_SHARED_LIBRARY_SONAME_CXX_FLAG><TARGET_SONAME>" "" CMAKE_CXX_CREATE_SHARED_MODULE "${CMAKE_CXX_CREATE_SHARED_MODULE}")
+
ADD_LIBRARY(SampleBrowserDummy MODULE ${CMAKE_CURRENT_BINARY_DIR}/dummy.cpp)
target_link_libraries(SampleBrowserDummy ${SAMPLE_LIBRARIES})
add_dependencies(SampleBrowserDummy ${OGRE_SAMPLES_LIST})
Third try:
make -j2
THIRD ERROR:
Code: Select all
Updated project.properties
Updated local.properties
Updated file /home/vigilant/Downloads/Repositories.Develop/ogre3d-2.0-repo/build-android-release/SampleBrowserNDK/proguard-project.txt
Android NDK: ERROR:jni/Android.mk:Sample_ShaderSystem: LOCAL_SRC_FILES points to a missing file
Android NDK: Check that /home/vigilant/Downloads/Repositories.Develop/ogre3d-2.0-repo/build-android-release/lib/libSample_ShaderSystem.a exists or that its path is correct
/home/.opt/android-ndk/build/core/prebuilt-library.mk:45: *** Android NDK: Aborting . Stop.
make[2]: *** [Samples/Browser/CMakeFiles/SampleBrowserDummy.dir/build.make:97: lib/libSampleBrowserDummy.so] Error 2
make[2]: *** Deleting file 'lib/libSampleBrowserDummy.so'
make[1]: *** [CMakeFiles/Makefile2:3558: Samples/Browser/CMakeFiles/SampleBrowserDummy.dir/all] Error 2
make: *** [Makefile:150: all] Error 2
FIX: (Remove Sample_Terrain and Sample_ShaderSystem - they're not being built anyway)
Code: Select all
--- a/Samples/Browser/CMakeLists.txt Wed Jun 22 09:07:58 2016 +0200
+++ b/Samples/Browser/CMakeLists.txt Wed Jul 20 09:57:40 2016 +0200
@@ -197,7 +197,7 @@
SET(HEADERS "")
SET(SAMPLE_LDLIBS "")
- add_static_libs("${OGRE_BINARY_DIR}/lib" "Sample_Water" "Sample_Ocean" "Sample_NewInstancing" "Sample_ShaderSystem" "Sample_EndlessWorld" "Sample_VolumeCSG" "Sample_VolumeTerrain" "Sample_Terrain")
+ add_static_libs("${OGRE_BINARY_DIR}/lib" "Sample_Water" "Sample_Ocean" "Sample_NewInstancing" "Sample_EndlessWorld" "Sample_VolumeCSG" "Sample_VolumeTerrain")
if(NOT ANDROID_GLES_ONLY)
add_static_libs("${OGRE_BINARY_DIR}/lib" "Sample_FacialAnimation" "Sample_Fresnel" "Sample_Grass" "Sample_ParticleFX" "Sample_MeshLod" "Sample_SkyBox" "Sample_SkyPlane" "Sample_SkyDome" "Sample_Smoke")
add_static_libs("${OGRE_BINARY_DIR}/lib" "Sample_CameraTrack" "Sample_CelShading" "Sample_Character" "Sample_Compositor" "Sample_Lighting" "Sample_BezierPatch" "Sample_CubeMapping" "Sample_DynTex")
Fourth try:
make -j2
FOURTH ERROR:
While reconfiguring CMake project (because CMakeLists.txt changed):
Code: Select all
The dependency target "Plugin_OctreeSceneManager" of target
"SampleBrowserDummy" does not exist.
Call Stack (most recent call first):
Samples/Browser/CMakeLists.txt:234 (create_android_proj)
This warning is for project developers. Use -Wno-dev to suppress it.
While building SampleBrowserDummy:
Code: Select all
Android NDK: ERROR:jni/Android.mk:Plugin_OctreeSceneManagerStatic: LOCAL_SRC_FILES points to a missing file
Android NDK: Check that /home/vigilant/Downloads/Repositories.Develop/ogre3d-2.0-repo/build-android-release/lib/libPlugin_OctreeSceneManagerStatic.a exists or that its path is correct
/home/.opt/android-ndk/build/core/prebuilt-library.mk:45: *** Android NDK: Aborting . Stop.
make[2]: *** [Samples/Browser/CMakeFiles/SampleBrowserDummy.dir/build.make:97: lib/libSampleBrowserDummy.so] Error 2
make[2]: *** Deleting file 'lib/libSampleBrowserDummy.so'
make[1]: *** [CMakeFiles/Makefile2:3558: Samples/Browser/CMakeFiles/SampleBrowserDummy.dir/all] Error 2
make: *** [Makefile:150: all] Error 2
FIX (edit CMake/Utils/AndroidMacros.cmake):
Code: Select all
--- a/CMake/Utils/AndroidMacros.cmake Wed Jun 22 09:07:58 2016 +0200
+++ b/CMake/Utils/AndroidMacros.cmake Wed Jul 20 10:06:17 2016 +0200
@@ -47,7 +47,7 @@
SET(DEPENDENCIES OgreMain RenderSystem_GLES)
endif()
- SET(DEPENDENCIES ${DEPENDENCIES} OgreTerrain OgreRTShaderSystem OgreMeshLodGenerator OgreOverlay OgrePaging OgreVolume Plugin_ParticleFX Plugin_OctreeSceneManager)
+ SET(DEPENDENCIES ${DEPENDENCIES} OgreTerrain OgreRTShaderSystem OgreMeshLodGenerator OgreOverlay OgrePaging OgreVolume Plugin_ParticleFX)
add_dependencies(${ANDROID_PROJECT_TARGET} ${DEPENDENCIES})
set(DEPEND_STATIC_LIBS "")
foreach(DEPENDENCY ${DEPENDENCIES})
Fifth try:
make -j2
SUCCESS!!!
-rw-r--r-- 1 user users 54M 07-20 10:07 SampleBrowserNDK/bin/NativeActivity-debug.apk
Successfully uploaded it to the device with adb install! But as shown before, the program (SampleBrowser) just displays magenta screen and floods logcat with
I/Adreno-ES20(22012): <validate_vertex_attrib_state:53>: validate_vertex_attrib_state: No vertex attrib is enabled in a draw call!
Also forgot about -DOGRE_BUILD_ANDROID_JNI_SAMPLE=ON - @Seranth was also building it. There were many errors (all compilation errors). FIX:
Code: Select all
diff -r 8323e2268f11 OgreMain/src/Android/JNI/OgreActivityJNI.cpp
--- a/OgreMain/src/Android/JNI/OgreActivityJNI.cpp Wed Jun 22 09:07:58 2016 +0200
+++ b/OgreMain/src/Android/JNI/OgreActivityJNI.cpp Wed Jul 20 11:41:36 2016 +0200
@@ -197,17 +197,17 @@
if(gCompositorManager == NULL)
{
- pSceneMgr = gRoot->createSceneManager(Ogre::ST_GENERIC);
+ pSceneMgr = gRoot->createSceneManager(Ogre::ST_GENERIC, 1, INSTANCING_CULLING_SINGLETHREAD);
pCamera = pSceneMgr->createCamera("MyCam");
- gCompositorManager = mRoot->getCompositorManager2();
+ gCompositorManager = gRoot->getCompositorManager2();
if( !gCompositorManager->hasWorkspaceDefinition( "SampleBrowserWorkspace" ) )
{
gCompositorManager->createBasicWorkspaceDef( "SampleBrowserWorkspace",
Ogre::ColourValue( 1.0f, 0.0f, 0.0f ),
Ogre::IdString() );
}
- compositorManager->addWorkspace( pSceneMgr, gRenderWnd, pCamera,
+ gCompositorManager->addWorkspace( pSceneMgr, gRenderWnd, pCamera,
"SampleBrowserWorkspace", true );
}
} else {
@@ -239,3 +239,5 @@
}catch(Ogre::RenderingAPIException& ex) {}
}
}
+
+} // namespace
Notice the closing bracket at the end of code. It then builds successfully. Also file CMake/toolchain/AndroidJNI.cmake needed fixing like @Seranth described. When running on device (app OgreJNI) it shows only red screen and nothing happens (no error messages flooding logcat however).
So here is the list of files that needed changing in order to build SamplesBrowser and Ogre for Android:
./CMake/Utils/AndroidMacros.cmake
./CMake/toolchain/AndroidJNI.cmake
./OgreMain/src/Android/JNI/OgreActivityJNI.cpp
./OgreMain/src/OgrePlatformInformation.cpp
./Samples/Browser/CMakeLists.txt
PS: The version 1.10 (branch default) builds for Android practically out of the box (needed small fix with -soname error in Samples/Browser/CMakeLists.txt but that's because I'm using latest version of CMake). SampleBrowser version 1.10 runs on device properly (tested many samples).