[SOLVED] Compiling Ogre for android target aarch64 with boost support

Problems building or running the engine, queries about how to use features etc.
Post Reply
MikmakOne
Gnoblar
Posts: 2
Joined: Tue Jun 05, 2018 3:54 pm

[SOLVED] Compiling Ogre for android target aarch64 with boost support

Post by MikmakOne »

Hi all,
I almost did it but still am fighting with the boost support which is causing some cmake build issues.
I am compiling against the android-21 API with the aarch64-linux-android-4.9 toolchain the Ogre 1.10 release which seems a bit messy for what it is the boost support.
I will try to explain what the issue is but before let me specify that the cmake build procedure correctly detects both the boost headers and libs.
And this is the cmake build script that I am using:

Code: Select all

#!/bin/bash

DIR=$(pwd)

API_LEVEL=21

ABI_VER=arm64-v8a
#ABI_VER=armeabi-v7a

NDK_TOOLCHAIN=aarch64-linux-android-4.9
#NDK_TOOLCHAIN=arm-linux-androideabi-4.9

OGRE_INSTALL_PREFIX=$DIR/ogre_2_0/ogre
OGRE_DEPS=$DIR/ogre_deps/libs
OGRE_CMAKE_TOOLCHAIN=$DIR/ogre_2_0/CMake/toolchain/android.toolchain.cmake

mkdir -p ./ogre_2_0/build
cd ./ogre_2_0/build

#unset BOOST_INCLUDEDIR
#unset BOOST_LIBRARYDIR
#unset BOOST_ROOT
#export BOOST_INCLUDEDIR=$MYBOOST_INCDIR
#export BOOST_LIBRARYDIR=$MYBOOST_LIBSDIR
#export BOOST_ROOT=$BOOST_PATH

#BOOST_DIRS="-DBOOST_INCLUDEDIR=$BOOST_PATH/include/boost-1_67/boost -DBOOST_LIBRARYDIR=$BOOST_PATH/libs/lib"


MYBOOST_FLAGS="-DBoost_COMPILER=-gcc -DBoost_DEBUG=ON -DBoost_DETAILED_FAILURE_MSG=ON -DBoost_USE_STATIC_LIBS=ON -DBoost_USE_MULTITHREADED=ON -DBoost_USE_STATIC_RUNTIME=ON -DBoost_USE_DEBUG_LIBS=OFF -DBoost_USE_RELEASE_LIBS=ON -DBoost_NO_SYSTEM_PATHS=ON"
#MYBOOST_FLAGS="-DBoost_COMPILER=-gcc -DBoost_DEBUG=TRUE -DBoost_USE_STATIC_LIBS=ON -DBoost_USE_MULTITHREADED=ON -DBoost_USE_STATIC_RUNTIME=TRUE"

cmake -G"Unix Makefiles" -DCMAKE_MAKE_PROGRAM="$ANDROID_NDK/prebuilt/linux-x86_64/bin/make" -DCMAKE_TOOLCHAIN_FILE=$OGRE_CMAKE_TOOLCHAIN -DCMAKE_INSTALL_PREFIX=$OGRE_INSTALL_PREFIX $MYBOOST_FLAGS -DOGRE_DEPENDENCIES_DIR=$OGRE_DEPS -DBOOST_INCLUDEDIR=$OGRE_DEPS/include/boost -DANDROID_ABI=$ABI_VER -DANDROID_NATIVE_API_LEVEL=$API_LEVEL -DANDROID_TOOLCHAIN_NAME=$NDK_TOOLCHAIN .. && make all install

cd ../..
The main issue seems to be some messy pthread (STD thread support) which is fighting with the BOOST one and this happens only if boost is correctly detected (to be clear, this is the case when the configuration once completed shows the thread model to be background (boost)
As a result I get a CMakeOutput.log file with the following content:

Code: Select all

The target system is: Linux - 1 - aarch64
The host system is: Linux - 4.13.0-32-generic - x86_64
Determining size of void* passed with the following output:
Change Dir: /home/turlik/tmp/ogre_2_0_android/ogre_2_0/build/CMakeFiles/CMakeTmp

Run Build Command:"/home/turlik/NVPACK/android-ndk-r12b/prebuilt/linux-x86_64/bin/make" "cmTC_871f4/fast"
/home/turlik/NVPACK/android-ndk-r12b/prebuilt/linux-x86_64/bin/make -f CMakeFiles/cmTC_871f4.dir/build.make CMakeFiles/cmTC_871f4.dir/build
make[1]: Entering directory `/home/turlik/tmp/ogre_2_0_android/ogre_2_0/build/CMakeFiles/CMakeTmp'
Building C object CMakeFiles/cmTC_871f4.dir/OGRE_PTR_SIZE.c.o
/home/turlik/NVPACK/android-ndk-r12b/toolchains/aarch64-linux-android-4.9/prebuilt/linux-x86_64/bin/aarch64-linux-android-gcc -DANDROID -isystem /home/turlik/NVPACK/android-ndk-r12b/platforms/android-21/arch-arm64/usr/include -isystem /home/turlik/NVPACK/android-ndk-r12b/sources/cxx-stl/gnu-libstdc++/4.9/include -isystem /home/turlik/NVPACK/android-ndk-r12b/sources/cxx-stl/gnu-libstdc++/4.9/libs/arm64-v8a/include  -fexceptions -Wno-psabi --sysroot=/home/turlik/NVPACK/android-ndk-r12b/platforms/android-21/arch-arm64 -fsigned-char -no-canonical-prefixes -march=armv8-a -fdata-sections -ffunction-sections -Wa,--noexecstack     -o CMakeFiles/cmTC_871f4.dir/OGRE_PTR_SIZE.c.o   -c /home/turlik/tmp/ogre_2_0_android/ogre_2_0/build/CMakeFiles/CheckTypeSize/OGRE_PTR_SIZE.c
Linking C executable cmTC_871f4
/usr/local/bin/cmake -E cmake_link_script CMakeFiles/cmTC_871f4.dir/link.txt --verbose=1
/home/turlik/NVPACK/android-ndk-r12b/toolchains/aarch64-linux-android-4.9/prebuilt/linux-x86_64/bin/aarch64-linux-android-gcc -fexceptions -Wno-psabi --sysroot=/home/turlik/NVPACK/android-ndk-r12b/platforms/android-21/arch-arm64 -fsigned-char -no-canonical-prefixes -march=armv8-a -fdata-sections -ffunction-sections -Wa,--noexecstack     -Wl,--no-undefined -Wl,-allow-shlib-undefined -Wl,--gc-sections -Wl,-z,noexecstack -Wl,-z,relro -Wl,-z,now -Wl,-z,nocopyreloc  -rdynamic CMakeFiles/cmTC_871f4.dir/OGRE_PTR_SIZE.c.o -o cmTC_871f4  -L/libs/arm64-v8a  "/home/turlik/NVPACK/android-ndk-r12b/sources/cxx-stl/gnu-libstdc++/4.9/libs/arm64-v8a/libsupc++.a"
make[1]: Leaving directory `/home/turlik/tmp/ogre_2_0_android/ogre_2_0/build/CMakeFiles/CMakeTmp'


Determining if the include file pthread.h exists passed with the following output:
Change Dir: /home/turlik/tmp/ogre_2_0_android/ogre_2_0/build/CMakeFiles/CMakeTmp

Run Build Command:"/home/turlik/NVPACK/android-ndk-r12b/prebuilt/linux-x86_64/bin/make" "cmTC_4b55f/fast"
/home/turlik/NVPACK/android-ndk-r12b/prebuilt/linux-x86_64/bin/make -f CMakeFiles/cmTC_4b55f.dir/build.make CMakeFiles/cmTC_4b55f.dir/build
make[1]: Entering directory `/home/turlik/tmp/ogre_2_0_android/ogre_2_0/build/CMakeFiles/CMakeTmp'
Building C object CMakeFiles/cmTC_4b55f.dir/CheckIncludeFile.c.o
/home/turlik/NVPACK/android-ndk-r12b/toolchains/aarch64-linux-android-4.9/prebuilt/linux-x86_64/bin/aarch64-linux-android-gcc -DANDROID -isystem /home/turlik/NVPACK/android-ndk-r12b/platforms/android-21/arch-arm64/usr/include -isystem /home/turlik/NVPACK/android-ndk-r12b/sources/cxx-stl/gnu-libstdc++/4.9/include -isystem /home/turlik/NVPACK/android-ndk-r12b/sources/cxx-stl/gnu-libstdc++/4.9/libs/arm64-v8a/include  -fexceptions -Wno-psabi --sysroot=/home/turlik/NVPACK/android-ndk-r12b/platforms/android-21/arch-arm64 -fsigned-char -no-canonical-prefixes -march=armv8-a -fdata-sections -ffunction-sections -Wa,--noexecstack     -o CMakeFiles/cmTC_4b55f.dir/CheckIncludeFile.c.o   -c /home/turlik/tmp/ogre_2_0_android/ogre_2_0/build/CMakeFiles/CMakeTmp/CheckIncludeFile.c
Linking C executable cmTC_4b55f
/usr/local/bin/cmake -E cmake_link_script CMakeFiles/cmTC_4b55f.dir/link.txt --verbose=1
/home/turlik/NVPACK/android-ndk-r12b/toolchains/aarch64-linux-android-4.9/prebuilt/linux-x86_64/bin/aarch64-linux-android-gcc -fexceptions -Wno-psabi --sysroot=/home/turlik/NVPACK/android-ndk-r12b/platforms/android-21/arch-arm64 -fsigned-char -no-canonical-prefixes -march=armv8-a -fdata-sections -ffunction-sections -Wa,--noexecstack     -Wl,--no-undefined -Wl,-allow-shlib-undefined -Wl,--gc-sections -Wl,-z,noexecstack -Wl,-z,relro -Wl,-z,now -Wl,-z,nocopyreloc  -rdynamic CMakeFiles/cmTC_4b55f.dir/CheckIncludeFile.c.o -o cmTC_4b55f  -L/libs/arm64-v8a  "/home/turlik/NVPACK/android-ndk-r12b/sources/cxx-stl/gnu-libstdc++/4.9/libs/arm64-v8a/libsupc++.a"
make[1]: Leaving directory `/home/turlik/tmp/ogre_2_0_android/ogre_2_0/build/CMakeFiles/CMakeTmp'


Determining if the pthread_create exist passed with the following output:
Change Dir: /home/turlik/tmp/ogre_2_0_android/ogre_2_0/build/CMakeFiles/CMakeTmp

Run Build Command:"/home/turlik/NVPACK/android-ndk-r12b/prebuilt/linux-x86_64/bin/make" "cmTC_1f885/fast"
/home/turlik/NVPACK/android-ndk-r12b/prebuilt/linux-x86_64/bin/make -f CMakeFiles/cmTC_1f885.dir/build.make CMakeFiles/cmTC_1f885.dir/build
make[1]: Entering directory `/home/turlik/tmp/ogre_2_0_android/ogre_2_0/build/CMakeFiles/CMakeTmp'
Building C object CMakeFiles/cmTC_1f885.dir/CheckSymbolExists.c.o
/home/turlik/NVPACK/android-ndk-r12b/toolchains/aarch64-linux-android-4.9/prebuilt/linux-x86_64/bin/aarch64-linux-android-gcc -DANDROID -isystem /home/turlik/NVPACK/android-ndk-r12b/platforms/android-21/arch-arm64/usr/include -isystem /home/turlik/NVPACK/android-ndk-r12b/sources/cxx-stl/gnu-libstdc++/4.9/include -isystem /home/turlik/NVPACK/android-ndk-r12b/sources/cxx-stl/gnu-libstdc++/4.9/libs/arm64-v8a/include  -fexceptions -Wno-psabi --sysroot=/home/turlik/NVPACK/android-ndk-r12b/platforms/android-21/arch-arm64 -fsigned-char -no-canonical-prefixes -march=armv8-a -fdata-sections -ffunction-sections -Wa,--noexecstack     -o CMakeFiles/cmTC_1f885.dir/CheckSymbolExists.c.o   -c /home/turlik/tmp/ogre_2_0_android/ogre_2_0/build/CMakeFiles/CMakeTmp/CheckSymbolExists.c
Linking C executable cmTC_1f885
/usr/local/bin/cmake -E cmake_link_script CMakeFiles/cmTC_1f885.dir/link.txt --verbose=1
/home/turlik/NVPACK/android-ndk-r12b/toolchains/aarch64-linux-android-4.9/prebuilt/linux-x86_64/bin/aarch64-linux-android-gcc -fexceptions -Wno-psabi --sysroot=/home/turlik/NVPACK/android-ndk-r12b/platforms/android-21/arch-arm64 -fsigned-char -no-canonical-prefixes -march=armv8-a -fdata-sections -ffunction-sections -Wa,--noexecstack     -Wl,--no-undefined -Wl,-allow-shlib-undefined -Wl,--gc-sections -Wl,-z,noexecstack -Wl,-z,relro -Wl,-z,now -Wl,-z,nocopyreloc  -rdynamic CMakeFiles/cmTC_1f885.dir/CheckSymbolExists.c.o -o cmTC_1f885  -L/libs/arm64-v8a  "/home/turlik/NVPACK/android-ndk-r12b/sources/cxx-stl/gnu-libstdc++/4.9/libs/arm64-v8a/libsupc++.a"
make[1]: Leaving directory `/home/turlik/tmp/ogre_2_0_android/ogre_2_0/build/CMakeFiles/CMakeTmp'

File /home/turlik/tmp/ogre_2_0_android/ogre_2_0/build/CMakeFiles/CMakeTmp/CheckSymbolExists.c:
/* */
#include <pthread.h>

int main(int argc, char** argv)
{
  (void)argv;
#ifndef pthread_create
  return ((int*)(&pthread_create))[argc];
#else
  (void)argc;
  return 0;
#endif
}
It seems to me that the crucial part which is handling the threading support for Ogre is being located in the PATH_TO_OGRE_SRC/CMake/ConfigureBuild.cmake
And to be clear, I just tried to disable the pthread support there but with no luck.
Thanks you in advance!
Last edited by MikmakOne on Tue Jun 05, 2018 9:19 pm, edited 1 time in total.
MikmakOne
Gnoblar
Posts: 2
Joined: Tue Jun 05, 2018 3:54 pm

Re: Compiling Ogre for android target aarch64 with boost support

Post by MikmakOne »

Well, just downloaded Ogre 1.11 and I did notice that boost is not being used at all for the android target - this is the build config result:

Code: Select all

Building components:
  + Bites
  + HLMS [BETA]
  + MeshLodGenerator
  + Overlay
  + Paging
  + Property
  + Java/ JNI [BETA]
  + RTShader System
  + RTShader System Core Shaders
  + RTShader System Extensions Shaders
  + Terrain
  + Volume
Building plugins:
  + Octree scene manager
  + STBI codec (generic)
  + FreeImage codec (generic)
  + Particle FX
Building rendersystems:
  + OpenGL ES 2.x
Building executables:
  + Samples
Building core features:
  + Mesh Lod
  + DDS image codec (.dds)
  + PVRTC image codec (.pvr)
  + ETC image codec (.pkm, .ktx) 
  + ZIP archives

Build type:                      static
Thread safety:                   none
ResourceManager behaviour:       strict
Use double precision:            disabled
Nodes inherit transform:         disabled
Assert mode:                     release exceptions

----------------------------------------------------------------------------

-- Configuring done
-- Generating done
CMake Warning:
  Manually-specified variables were not used by the project:

    BOOST_INCLUDEDIR
    Boost_COMPILER
    Boost_DEBUG
    Boost_DETAILED_FAILURE_MSG
    Boost_NO_SYSTEM_PATHS
    Boost_USE_DEBUG_LIBS
    Boost_USE_MULTITHREADED
    Boost_USE_RELEASE_LIBS
    Boost_USE_STATIC_LIBS
    Boost_USE_STATIC_RUNTIME
    
I guess that the c++11 adoption for this release has let boost being marked as deprecated - also this is what it can be found in the main CMakeLists.txt
We can close this discussion then ;)
Post Reply