Building protobuff libs for Android 64 bit (ARM64-v8a) Qt 5.12.4

  • Hallo,

    I am trying to build the protobuff library for android using NDK r20b.
    I could not find proper solution for arm64-v8a all the links available are armv7-a

    I have generated the tool chain for aarch64_linux_android which is 64bit support on Qt Android (AFAIK).

    Below are few links i followed through and customized the script as per my requirement.

    Using aarch64_linux_android from tool chain build.

     export PATH=$HOME/Android/aarch64_linux_android/bin:$PATH
     export SYSROOT=$HOME/Android/aarch64_linux_android/sysroot
     export CC="arm-linux-androideabi-gcc --sysroot $SYSROOT"
     export CXX="arm-linux-androideabi-g++ --sysroot $SYSROOT"
     export CXXSTL=$NDK/sources/cxx-stl/gnu-libstdc++/4.6
     ./configure --prefix=$(pwd)/build \
     --host=aarch64_linux_android \
     --with-sysroot=$SYSROOT \
     --disable-shared \
     --enable-cross-compile \
     --with-protoc=protoc \
     CFLAGS="-march=lib64" \
     CXXFLAGS="-march=lib64 -I$CXXSTL/include -I$CXXSTL/libs/arm64-v8a/include"

    export CXXSTL=$NDK/sources/cxx-stl/gnu-libstdc++/4.6 we don't have this with ndkr20b

    Can anyone please help me to build the 64bit protobuff library for Android arm64-v8a ?

    Thanks in advance.

  • I don't know anything about protobuff, but if you don't specifically need NDK 20, I'd try with 19, as at least Qt 5.12.3 doesn't seem to like v 20.

  • Thanks @mvuori

    The issue is same with NDK 19.

    I can build it for below NDK 19 as they have sources/cxx-stl/gnu-libstdc++/4.6 but they come with armeabi-v7a which is for 32 bit (AFAIK).
    We need aarch64-linux-android for android 64 bit.

    Also the folder structure has completely changed from NDK 19.

  • Lifetime Qt Champion


    From a quick look, your -march values are wrong. There's no architecture named lib64. The correct value is more likely to be arm64-v8a.

  • Hi @SGaist

    I dont have these folders in the toolchain which i generated for NDK 20 & NDK 19
    I am also confused with the new folder structure in updated NDK code.

  • Lifetime Qt Champion

    What folder are you talking about ?

  • @SGaist
    NDK_ROOT/sources/cxx-stl has only llvm-libc++ & llvm-llibc++abi
    We need the clang for Qt 5.12.4
    And i want to build it for Android API 28 which is only supported from NDK 19

  • @SGaist

    Below is the script i have for building it.

    export PREFIX=$HOME/ARM64_Protobuf/protobuf/
    export PATH=$HOME/Android/NDK19/aarch64-linux-android-4.9/bin:$PATH
    export SYSROOT=$HOME/Android/NDK19/aarch64-linux-android-4.9/sysroot
    export CC="aarch64-linux-android-clang --sysroot $SYSROOT"
    export CXX="aarch64-linux-android-clang++ --sysroot $SYSROOT"
    ../configure \
    --prefix=$PREFIX \
    --host=aarch64-linux-android \
    --with-sysroot="${SYSROOT}" \
    --enable-shared \
    --enable-cross-compile \
    --with-protoc=protoc \
    CFLAGS="-march=arm64-v8a -D__ANDROID_API__=28" \
    CXXFLAGS="-frtti -fexceptions -march=arm64-v8a -D__ANDROID_API__=28" \
    LIBS="-llog -lz -lc++_static"
    make -j 2
    make install

    and i have the error below as

    checking whether to enable maintainer-specific portions of Makefiles... yes
    checking build system type... x86_64-pc-linux-gnu
    checking host system type... aarch64-unknown-linux-android
    checking target system type... aarch64-unknown-linux-android
    checking for a BSD-compatible install... /usr/bin/install -c
    checking whether build environment is sane... yes
    checking for aarch64-linux-android-strip... aarch64-linux-android-strip
    checking for a thread-safe mkdir -p... /bin/mkdir -p
    checking for gawk... no
    checking for mawk... mawk
    checking whether make sets $(MAKE)... yes
    checking whether make supports nested variables... yes
    checking whether UID '1000' is supported by ustar format... yes
    checking whether GID '1000' is supported by ustar format... yes
    checking how to create a ustar tar archive... gnutar
    checking whether make supports nested variables... (cached) yes
    checking for aarch64-linux-android-gcc... aarch64-linux-android-clang --sysroot /home/Android/NDK19/aarch64-linux-android-4.9/sysroot
    checking whether the C compiler works... no
    configure: error: in `/home/ARM64_Protobuf/protobuf/build':
    configure: error: C compiler cannot create executables
    See `config.log' for more details
    make: *** No targets specified and no makefile found.  Stop.
    make: *** No rule to make target `install'.  Stop.

  • Lifetime Qt Champion

    What does the config.log tell you ?

  • @SGaist Thanks for the support.

    I was able to build the library & protoc for Android ARM 64 v8a using Ubuntu 16.04 LTS.
    I am moving it to Solved. If some one comes up with the same issue/problem I can support on that.

  • Lifetime Qt Champion

    Glad you succeeded. It would be nice to have a write down of what you did to be able to achieve the build.

  • Hello @Pradeep-P-N,

    I'm trying to build protobuf for arm64 and I have the same error. How did you solve the problem?

    Thank you

Log in to reply