Skip to content

Command line Android builds #513

@GoodOldGamer

Description

@GoodOldGamer

I'm trying to build the library mtxclient from the nheko project for Android. They offer the option to download & build dependencies like OpenSSL, libcurl etc. via Hunter, which works fine for Linux, but fails for Android-

In my first try, cmake was defaulting to arm with API level 16 because ANDROID_PLATFORM was not set. This resulted of course in an ABI mismatch when the dependencies were linked against the mtxclient lib. So I forwarded the CMAKE_ARGS in hunter_config:

hunter_config(
      OpenSSL
      VERSION 1.1.1j
      CMAKE_ARGS 
        ANDROID_ABI=${ANDROID_ABI} 
        ANDROID_PLATFORM=${ANDROID_PLATFORM}
        ANDROID_NDK=${ANDROID_NDK}
        ANDROID_SDK=${ANDROID_SDK}
        ANDROID_STL=${ANDROID_STL}
)

But this lead to a linker error while linking the dependency against system libs:
ld: error: unable to find library -l-l:libunwind.a

I'm using the following environment and cmake call to build the lib:

export ANDROID_ABI=x86
export ANDROID_API_LEVEL=21
export ANDROID_PLATFORM=android-${ANDROID_API_LEVEL}
export ANDROID_SDK_DIR=${HOME}/apps/Android/SDK
export ANDROID_NDK_DIR=${HOME}/apps/Android/SDK/ndk/23.1.7779620

mkdir -p build/android/${ANDROID_ABI}
cd build/android/${ANDROID_ABI}

cmake \
    -DANDROID_ABI:STRING=${ANDROID_ABI} \
    -DANDROID_PLATFORM=${ANDROID_PLATFORM} \
    -DANDROID_NDK:PATH=${ANDROID_NDK_DIR} \
    -DANDROID_SDK:PATH=${ANDROID_SDK_DIR} \
    -DANDROID_STL:STRING=c++_shared \
    -DCMAKE_BUILD_TYPE:STRING=Release \
    -DCMAKE_CXX_COMPILER:STRING=${ANDROID_NDK_DIR}/toolchains/llvm/prebuilt/linux-x86_64/bin/clang++ \
    -DCMAKE_C_COMPILER:STRING=${ANDROID_NDK_DIR}/toolchains/llvm/prebuilt/linux-x86_64/bin/clang \
    -DCMAKE_TOOLCHAIN_FILE:PATH=${ANDROID_NDK_DIR}/build/cmake/android.toolchain.cmake \
    -DCMAKE_INSTALL_PREFIX=${HOME}/development/build/mtxclient/${ANDROID_ABI} \
    -DHUNTER_ENABLED=ON \
    -DUSE_BUNDLED_COEURL=yes \
    -DUSE_BUNDLED_LIBEVENT=yes \
    -DUSE_BUNDLED_LIBCURL=yes \
    -DUSE_BUNDLED_SPDLOG=yes \
    -DUSE_BUNDLED_OLM=yes \
    -DUSE_BUNDLED_GTEST=yes \
    -DUSE_BUNDLED_JSON=yes \
    -DUSE_BUNDLED_OPENSSL=yes \
    ../../..

What's the right way of passing ABI and API level to Hunter dependencies when building for Android?
Is it still up to date that NDK version 19+ is not supported by built-in CMake modules?

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions