-
Notifications
You must be signed in to change notification settings - Fork 52
Cross Compiling BioGears for Android
Cross compilation of Native C++ Libraries is an intermediate to expert skill that requires knowledge of the workings of compilers, linker, and system tool-chains in general. Android is a multi platform OS that can be deployed on over 5 processor architectures which further complicates the generation of documentation on how to generate Android builds. This documentation focuses on the generation of aarch64 builds fro targeting the majority of Android Mobile Phones. Targeting this platform requires familiarity with the Android Native Development Kit (NDK) and integration in to an APK requires familiarity of the Android Software Development Kit (SDK). Incorporating Bio Gears in to your own Android project is outside of scope of this documentation and we refer you to the following resources for learning how to make Android projects before attempting incorporation of a large project like BioGears in to your own project.
Instead this documentation focuses on the creation of Architecture appropriate binaries for libBioGears and its dependencies using the toolchain and compilers provided by the Android NDK. This documentation will call out specific versions of the Android NDK that were tested against the instructions. While other versions of the NDK should be able to compile BioGears for Android correctly, they are untested and may require additional instructional as compiler versions and header storage with in the NDK change over time. Additionally, methods of using CMake with the NDK are improving with each release and may be different then the NDKs referenced in these instructions. That said the NDK versions referenced in these instructions should provide compatible binaries for all Android phones up to 2022.
Warning: This documentation is intended for those failure with concepts of C++ and Mobile development. It assumes you are capable of setting up your own build environments and makes assumptions about your ability to manage your personal environment variables. This documentation is open source and does accept contributions to improve clarity
- Android NDK - android-ndk-r17c - Last GCC Release / Last gnustl release - June 2018
- Android SDK - API Level 29 / 30 - 2019
For this documentation I will be referring to the BioGears MetaBuild CMakeLists.txt. The purpose of this file is to simplify gathering of all the required third party libraries needed to make a cross compilation. The script is attached to this documentation
cmake -G "Unix Makefiles" \
-B "C:/biogears\build-android" \
-S "C:/biogears" \
-D CMAKE_BUILD_TYPE="Release" \
-D CMAKE_MAKE_PROGRAM="C:/Program Files/Kitware/CMake/cmake.exe"
-D CMAKE_TOOLCHAIN_FILE="%NDK_HOME%\build/cmake/" \
-D ANDROID_STL="gnustl_shared" \
-D ANDROID_CPP_FEATURES='rtti;exceptions' \
-D ANDROID_ABI="arm64-v8a" \
-D ANDROID_ARM_NEON="ON" \
-D ANDROID_PLATFORM="android-24" \
-D CMAKE_INSTALL_PREFIX="C:/biogears/install/android" \
-D CMAKE_PREFIX_PATH="C:/biogears/external/windows" \
-D CMAKE_FIND_ROOT_PATH="C:/biogears/install/android" \
-D CMAKE_BUILD_TYPE="Release" \
-D XERCES_C_transcoder=icu" \
-D BG_META_PLATFORM="Android" \
-D BG_META_ARCHITECTURE="arm64-v8a" \
-D BG_META_CONFIGURATION="rel" \
-D NATIVE_CODE_GENERATOR="Visual Studio 17 2022 Win64"