Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

why android ndk standalone toolchain do not support arm64 with api 19 but android ndk cmake does

I used to build arm64-v8a lib of api level 19 use android.toolchain.cmake comes with Android NDK r16b like this.

${CMAKE} \
        -DCMAKE_TOOLCHAIN_FILE=${TOOLCHAIN_FILE}                    \
        -DANDROID_NDK=$ANDROID_NDK_HOME                             \
        -DANDROID_ABI="arm64-v8a"                                   \
        -DANDROID_NATIVE_API_LEVEL="android-19"                     \
        -DANDROID_STL="c++_shared"                                  \
        -DANDROID_CPP_FEATURES="rtti exceptions"                    \
        ..

Now i want to pack my lib use conan which cross compile android lib use standalone toolchain. Its seems to be impossible to make standalone toolchain with --arch arm64 and --api 19, since the following command

./make_standalone_toolchain.py --arch=arm64 --api=19 --stl=libc++ --install-dir=./test

will fail with error message:

19 is less than minimum platform for arm64 (21)

is there any way to fix this?

like image 781
guorongfei Avatar asked Apr 08 '18 03:04

guorongfei


People also ask

How do I know what version of NDK I have?

Go to Tools->SDK Manager (or Files->Settings->Appearance & Behavior->System Settings->Android SDK ). Then select the SDK Tools tab, and check the Show Package Details checkbox. You will see your NDK version.

How do I know if android NDK is installed?

You'll need to point to your NDK in your eclipse by adding the path of ndk-build to Window > preferences > android > NDK. Right click on your project folder. Choose android tools -> add native support (the bottom one) and click finish.

What is NDK Sysroot?

A sysroot is a directory containing the system headers and libraries for your target. To define the sysroot, you must must know the Android API level you want to target for native support; available native APIs vary by Android API level.


1 Answers

Because there's no such thing as API 19 ARM64. 64-bit support was added in android-21.

CMake supports this because our toolchain file was modeled off of a popular option that was commonly used at the time and that's what it did. ndk-build does it because you build multiple ABIs in a single invocation. In both cases, the build automatically pulls the API level up to 21 for 64-bit targets.

Standalone toolchains are for exactly one architecture, so they give an error if you specify an API level that is not supported by that architecture since it was likely a mistake.

like image 57
Dan Albert Avatar answered Nov 15 '22 09:11

Dan Albert