Skip to content

Android build

Juan David Adarve edited this page May 9, 2019 · 3 revisions

NDK setup

Following instructions prepare the Android NDK for compiling lluvia.

  • Install Android NDK r19 or newer.
  • Define the ANDROID_NDK environment variable pointing to the root directory of the NDK.
  • Build the NDKs shaderc library. From Android developer:
cd $ANDROID_NDK/sources/third_party/shaderc

../../../ndk-build NDK_PROJECT_PATH=. APP_BUILD_SCRIPT=Android.mk \
APP_STL:=c++_shared APP_ABI=all libshaderc_combined
  • Copy a compatible vulkan.hpp header into $ANDROID_NDK/toolchains/llvm/prebuilt/linux-x86_64/sysroot/usr/include/vulkan/. For NDK r19c, which defines VK_HEADER_VERSION = 82, the compatible vulkan.hpp header can be copied from the LunarG 1.1.82.1 SDK version. See https://github.com/android-ndk/ndk/issues/945 for more information.
sudo cp $VULKAN_SDK/include/vulkan/vulkan.hpp \
        $ANDROID_NDK/toolchains/llvm/prebuilt/linux-x86_64/sysroot/usr/include/vulkan/

Compilation

The utility script tools/ll-build-android can be used to compile lluvia for the different supported ABIs:

tools/ll-build-android --type release build_android

This will create a folder build_android/release containing the compiled static libraries for arm64-v8a, armeabi-v7a, x86 and x86_64 ABIs.

Integration into an Android native project

  • Include the paths to lluvia's include directories in the CMakeLists.txt of your app:
include_directories(
        <path_to_lluvia>/core/include
        <path_to_lluvia>/thirdparty
)
  • Add the following libraries to your target_lib_libraries command:
target_link_libraries( # Specifies the target library.
        <your_target_name>
        <path_to_lluvia>/build_android/release/${ANDROID_ABI}/lib/liblluvia-core.a
        vulkan)

If you compiled lluvia as Debug tools/ll-build-android --type debug build_android, you need to change the path in target_link_libraries accordingly.

Clone this wiki locally