Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Mobile and Embedded
  4. Building protobuff libs for Android 64 bit (ARM64-v8a) Qt 5.12.4
Forum Updated to NodeBB v4.3 + New Features

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

Scheduled Pinned Locked Moved Solved Mobile and Embedded
24 Posts 6 Posters 7.4k Views 2 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • Pradeep P NP Pradeep P N

    Build Instructions on Ubuntu 16.04 LTS

    Building Android Tool Chain :

    • Few Dependencies :
      sudo apt-get install autoconf automake libtool curl make g++ unzip python gcc git

    • Download NDK - Latest Stable Version ( I used NDK r20b, which was latest during i built it )

    • You may want to append export NDK=$HOME/<path-to-NDK> to your ~/.bashrc
      echo $NDK to verify NDK path from above.

    • Creating the Standalone toolchain.
      The NDK folder contains default toolchains, or we can build it - Standalone Toolchains (Obsolete)
      Example

         $NDK/build/tools/make_standalone_toolchain.py \
               --arch arm64 \
               --api 28 \
               --stl=libc++ \
               --install-dir=$HOME/<path-to-build-dir>
    
    • You may want to append export PATH=$HOME/<path-to-build-dir/bin:$PATH to your ~/.bashrc
      echo $PATH to verify toolchain path.

    Building Google’s Protobuf library :

    • Clone protobuf
      mkdir $HOME/Android/NDK/google
     
      cd $HOME/Android/NDK/google
    
      git clone https://github.com/protocolbuffers/protobuf.git
    
      cd protobuf
    
      git submodule update --init --recursive
    
    # Checkout if specific version is needed, example as shown below, else ignore the below command 
     git checkout -b v3.5.2 v3.5.2
    
    
    • Build a native (x86) version of the protobuf libraries and compiler (protoc)
      sudo apt-get install curl autoconf libtool build-essential g++

    In protobuf folder

    ./autogen.sh
    
     mkdir x86_build
     cd x86_build
    
    # x86_pb_install folder should be created manually at below given path then run the below cmd
    
     ../configure --prefix=$HOME/Android/NDK/google/x86_pb_install 
    
     make install –j4
    
     cd ..
    

    Libraries will been installed in: $HOME/Android/NDK/google/x86_pb_install/lib
    protoc will be in: $HOME/Android/NDK/google/x86_pb_install/bin
    include files will be in: $HOME/Android/NDK/google/x86_pb_install/include

    • Build the arm64 version of the protobuf libraries:
     mkdir arm64_build
    
     cd arm64_build
    
     # arm64_pb_install folder should be created manually at below given path then run the below cmd
    
      CC=aarch64-linux-android-clang \
      CXX=aarch64-linux-android-clang++ \
      CFLAGS="-fPIE -fPIC" LDFLAGS="-pie -llog" \
         ../configure --host=aarch64-linux-android \
         --prefix=$HOME/Android/NDK/google/arm64_pb_install \
         --with-protoc=$HOME/Android/NDK/google/x86_pb_install/bin/protoc
    
      make install –j4
    
      cd ..
    
    

    Libraries will been installed in: $HOME/Android/NDK/google/arm64_pb_install/lib
    protoc will be in: $HOME/Android/NDK/google/arm64_pb_install/bin
    include files will be in: $HOME/Android/NDK/google/arm64_pb_install/include

    • Compiling Your Protocol Buffers
      protoc -I=$SRC_DIR --cpp_out=$DST_DIR $SRC_DIR/file_name.proto

    @SGaist
    Hope this helps

    @Chapay, @Clem3nt
    If possible please try this and update me.

    mbruelM Offline
    mbruelM Offline
    mbruel
    wrote on last edited by
    #21

    @Pradeep-P-N

    Thanks for this.
    It's working fine.
    Little remark from Nov 2020, the script make_standalone_toolchain.py is no longer needed:

    #$ $NDK/build/tools/make_standalone_toolchain.py --arch arm64 --api 28 --stl=libc++ --install-dir=/home/bruel/apps/protobuf/build
    #WARNING:__main__:make_standalone_toolchain.py is no longer necessary. The
    #$NDK/toolchains/llvm/prebuilt/linux-x86_64/bin directory contains target-specific scripts that perform
    #the same task. For example, instead of:
    #
    #    $ python $NDK/build/tools/make_standalone_toolchain.py \
    #        --arch arm64 --api 28 --install-dir toolchain
    #    $ toolchain/bin/clang++ src.cpp
    #
    #Instead use:
    #
    #    $ $NDK/toolchains/llvm/prebuilt/linux-x86_64/bin/aarch64-linux-android28-clang++ src.cpp
    

    So for arm64, you can go directly like this
    CC=$NDK/toolchains/llvm/prebuilt/linux-x86_64/bin/aarch64-linux-android$ANDROID_API-clang CXX=$NDK/toolchains/llvm/prebuilt/linux-x86_64/bin/aarch64-linux-android$ANDROID_API-clang++ CFLAGS="-fPIE -fPIC" LDFLAGS="-pie -llog" ../configure --host=aarch64-linux-android --prefix=$APPS_DIR/protobuf/release/arm64 --with-protoc=~/apps/protobuf/release/x86_64/bin/protoc

    For those interested, here is my script to build on Linux for x86_64, arm64 and armv7a.

    Pradeep P NP 1 Reply Last reply
    1
    • mbruelM mbruel

      @Pradeep-P-N

      Thanks for this.
      It's working fine.
      Little remark from Nov 2020, the script make_standalone_toolchain.py is no longer needed:

      #$ $NDK/build/tools/make_standalone_toolchain.py --arch arm64 --api 28 --stl=libc++ --install-dir=/home/bruel/apps/protobuf/build
      #WARNING:__main__:make_standalone_toolchain.py is no longer necessary. The
      #$NDK/toolchains/llvm/prebuilt/linux-x86_64/bin directory contains target-specific scripts that perform
      #the same task. For example, instead of:
      #
      #    $ python $NDK/build/tools/make_standalone_toolchain.py \
      #        --arch arm64 --api 28 --install-dir toolchain
      #    $ toolchain/bin/clang++ src.cpp
      #
      #Instead use:
      #
      #    $ $NDK/toolchains/llvm/prebuilt/linux-x86_64/bin/aarch64-linux-android28-clang++ src.cpp
      

      So for arm64, you can go directly like this
      CC=$NDK/toolchains/llvm/prebuilt/linux-x86_64/bin/aarch64-linux-android$ANDROID_API-clang CXX=$NDK/toolchains/llvm/prebuilt/linux-x86_64/bin/aarch64-linux-android$ANDROID_API-clang++ CFLAGS="-fPIE -fPIC" LDFLAGS="-pie -llog" ../configure --host=aarch64-linux-android --prefix=$APPS_DIR/protobuf/release/arm64 --with-protoc=~/apps/protobuf/release/x86_64/bin/protoc

      For those interested, here is my script to build on Linux for x86_64, arm64 and armv7a.

      Pradeep P NP Offline
      Pradeep P NP Offline
      Pradeep P N
      wrote on last edited by
      #22

      Hi @mbruel

      That's cool,
      I had a critical time & had to go with make_standalone_toolchain.py at that time.

      Thanks for the updated script on this Building protobuff libs for Android 64 bit (ARM64-v8a) Qt 5.12.4.

      Pradeep Nimbalkar.
      Upvote the answer(s) that helped you to solve the issue...
      Keep code clean.

      1 Reply Last reply
      0
      • mbruelM Offline
        mbruelM Offline
        mbruel
        wrote on last edited by
        #23

        In fact with the method I've posted just above, I can build the Android arm64 library but when I deploy it to a device it's crashing with this:

        E AndroidRuntime: FATAL EXCEPTION: qtMainLoopThread
        E AndroidRuntime: Process: fr.mbruel.ClementineRemote, PID: 24487
        E AndroidRuntime: java.lang.UnsatisfiedLinkError: dlopen failed: cannot locate symbol "_Unwind_Resume" referenced by "/data/app/fr.mbruel.ClementineRemote-eCT926MVQi5HkO3nFNVzEg==/lib/arm64/libprotobuf.so"...
        E AndroidRuntime: 	at java.lang.Runtime.load0(Runtime.java:938)
        E AndroidRuntime: 	at java.lang.System.load(System.java:1631)
        E AndroidRuntime: 	at org.qtproject.qt5.android.QtNative$3.run(QtNative.java:348)
        E AndroidRuntime: 	at org.qtproject.qt5.android.QtThread$2.run(QtThread.java:87)
        E AndroidRuntime: 	at org.qtproject.qt5.android.QtThread$1.run(QtThread.java:61)
        E AndroidRuntime: 	at java.lang.Thread.run(Thread.java:919)
        

        Any idea why?
        I'm using protobuf 3.13. I've tried the latest 3.17 but I've the same issue...
        I'm building using this command:

        NDK=~/android/android-ndk-r21
        ANDROID_API=29
        
        CC=$NDK/toolchains/llvm/prebuilt/linux-x86_64/bin/aarch64-linux-android$ANDROID_API-clang CXX=$NDK/toolchains/llvm/prebuilt/linux-x86_64/bin/aarch64-linux-android$ANDROID_API-clang++ CFLAGS="-fPIE -fPIC" LDFLAGS="-pie -llog" ../configure --host=aarch64-linux-android --prefix=~/apps/protobuf/release/arm64 --with-protoc=~/apps/protobuf/release/x86_64/bin/protoc
        
        1 Reply Last reply
        0
        • mbruelM Offline
          mbruelM Offline
          mbruel
          wrote on last edited by
          #24

          @mbruel said in Building protobuff libs for Android 64 bit (ARM64-v8a) Qt 5.12.4:

          cannot locate symbol "_Unwind_Resume"

          I've updated the NDK to the r21e and the crash is gone! \o/

          1 Reply Last reply
          2

          • Login

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • Users
          • Groups
          • Search
          • Get Qt Extensions
          • Unsolved