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. Compiling openssl for use with Qt 5.12 on Android
Forum Updated to NodeBB v4.3 + New Features

Compiling openssl for use with Qt 5.12 on Android

Scheduled Pinned Locked Moved Unsolved Mobile and Embedded
opensslqt5.12android
6 Posts 3 Posters 1.9k 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.
  • K Offline
    K Offline
    koahnig
    wrote on 14 Jun 2019, 15:21 last edited by koahnig
    #1

    Trying to compile openssl for use with Android and Qt 5.12.

    Qt 5.12 requires the latest android ndk. However, this ndk does not support *-gcc

    $ ../Setenv-android.sh
    Error: Failed to find arm-linux-androideabi-gcc. Please edit this script.
    Error: FIPS_SIG does not specify incore module. Please edit this script.
    ANDROID_NDK_ROOT: c:/Users/xxxxx/AppData/Local/Android/Sdk/ndk-bundle
    ANDROID_ARCH: arch-arm
    ANDROID_EABI: arm-linux-androideabi-4.9
    ANDROID_API: android-18
    ANDROID_SYSROOT: c:/Users/xxxxx/AppData/Local/Android/Sdk/ndk-bundle/platforms/android-18/arch-arm
    ANDROID_TOOLCHAIN: c:/Users/xxxxx/AppData/Local/Android/Sdk/ndk-bundle/toolchains/arm-linux-androideabi-4.9/prebuilt/windows-x86_64/bin
    FIPS_SIG:
    CROSS_COMPILE: arm-linux-androideabi-
    ANDROID_DEV: c:/Users/xxxxx/AppData/Local/Android/Sdk/ndk-bundle/platforms/android-18/arch-arm/usr
    

    Anyone an idea how to move forward?

    Vote the answer(s) that helped you to solve your issue(s)

    1 Reply Last reply
    0
    • S Offline
      S Offline
      SGaist
      Lifetime Qt Champion
      wrote on 14 Jun 2019, 19:54 last edited by
      #2

      Hi,

      What instructions are you following ?

      The NDK switched to clang. One quick and dirty way could be to create two symbolic links for gcc and g++ to the corresponding clang and clang++ binaries.

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      K 1 Reply Last reply 14 Jun 2019, 21:14
      1
      • S SGaist
        14 Jun 2019, 19:54

        Hi,

        What instructions are you following ?

        The NDK switched to clang. One quick and dirty way could be to create two symbolic links for gcc and g++ to the corresponding clang and clang++ binaries.

        K Offline
        K Offline
        koahnig
        wrote on 14 Jun 2019, 21:14 last edited by
        #3

        @SGaist said in Compiling openssl for use with Qt 5.12 on Android:

        What instructions are you following ?

        https://doc.qt.io/qt-5/android-openssl-support.html

        The NDK switched to clang. One quick and dirty way could be to create two symbolic links for gcc and g++ to the corresponding clang and clang++ binaries.

        Not completely clear right away to me.

        Vote the answer(s) that helped you to solve your issue(s)

        1 Reply Last reply
        0
        • S Offline
          S Offline
          SGaist
          Lifetime Qt Champion
          wrote on 14 Jun 2019, 21:21 last edited by
          #4

          Ok, then these instructions are for the older NDK r10.

          I meant go to the folder where clang is located and then ln -s clang gcc and ln -s clang++ g++

          Interested in AI ? www.idiap.ch
          Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

          1 Reply Last reply
          0
          • A Offline
            A Offline
            ashajg
            wrote on 20 Jun 2019, 11:31 last edited by ashajg
            #5

            Hi ,
            This is what I did last year to compile openssl for android using windows system

            SOFTWARES REQUIRED*****

            MinGW
            MSYS2
            PERL(5.10 or above)
            ANDROID NDK
            OPENSSL SOURCE CODE

            PROCESS FOLLOWED****

            STEP 1: Install MSYS2
            STEP 2: DOWNLOAD and install ALL THE IMPORTANT MODULES of MSYS2 using following commands
            step 2.1: pacman -Syu
            step 2.2: pacman -Su
            step 2.3: pacman -S git
            STEP 3: DOWNLOAD OPENSSL-1.1.1 and Setenv-android.sh script(from openssl official website)
            STEP 4: MODIFY Setenv-android.sh script according to your need.

            EDIT the script to get something like this
            $ bash setenv-android.sh
            ANDROID_NDK_ROOT: C:/Android/android-ndk-r15c
            ANDROID_ARCH: arch-arm
            ANDROID_EABI: arm-linux-androideabi-4.9
            ANDROID_API: android-24
            ANDROID_SYSROOT: C:/Android/android-ndk-r15c/platforms/android-24/arch-arm
            ANDROID_TOOLCHAIN: C:/Android/android-ndk-r15c/toolchains/arm-linux-androideabi-4.9/prebuilt/windows-x86_64/bin
            FIPS_SIG:
            CROSS_COMPILE: arm-linux-androideabi-
            ANDROID_DEV: C:/Android/android-ndk-r15c/platforms/android-24/arch-arm/usr

            STEP 5: CREATE A ROOT FOLDER AND PASTE THIS SCRIPT AND OPENSSL-1.1.1 folder in that folder
            STEP 6: OPEN MSYS2 and navigate to root folder
            STEP 7: RUN FOLLOWING COMMANDS
            chmod a+x Setenv-android.sh
            . ./Setenv-android.sh
            STEP 8: NOW navigate to openssl1.1.1 folder which is present inside root folder
            cd openssl-1.1.1
            STEP 9: NOW run these commands
            1)./config shared
            2)perl configdata.pm --dump
            3)make depend
            4)make all
            NOTE: IF make gives error just run "$ pacman -S make" command..
            STEP 10: THIS process should give library files in openssl folder ..........

            Try this once😊

            Make sure that whatever paths you set in this script shall be correct else you may get error!!!

            Note : used ndk-r15c

            1 Reply Last reply
            0
            • A Offline
              A Offline
              ashajg
              wrote on 20 Jun 2019, 12:03 last edited by
              #6

              sample of script:

              #!/bin/bash
              # Cross-compile environment for Android on ARMv7 and x86
              #
              # Contents licensed under the terms of the OpenSSL license
              # http://www.openssl.org/source/license.html
              #
              # See http://wiki.openssl.org/index.php/FIPS_Library_and_Android
              #   and http://wiki.openssl.org/index.php/Android
              
              #####################################################################
              export ANDROID_NDK_ROOT="/c/ASHISH/android-ndk-r15c"
              # Set ANDROID_NDK_ROOT to you NDK location. For example,
              # /opt/android-ndk-r8e or /opt/android-ndk-r9. This can be done in a
              # login script. If ANDROID_NDK_ROOT is not specified, the script will
              # try to pick it up with the value of _ANDROID_NDK_ROOT below. If
              # ANDROID_NDK_ROOT is set, then the value is ignored.
              # _ANDROID_NDK="android-ndk-r8e"
              #_ANDROID_NDK="android-ndk-r9"
              # _ANDROID_NDK="android-ndk-r10"
              
              # Set _ANDROID_EABI to the EABI you want to use. You can find the
              # list in $ANDROID_NDK_ROOT/toolchains. This value is always used.
              # _ANDROID_EABI="x86-4.6"
              # _ANDROID_EABI="arm-linux-androideabi-4.6"
              _ANDROID_EABI="arm-linux-androideabi-4.9"
              
              # Set _ANDROID_ARCH to the architecture you are building for.
              # This value is always used.
              # _ANDROID_ARCH=arch-x86
              _ANDROID_ARCH=arch-arm
              
              # Set _ANDROID_API to the API you want to use. You should set it
              # to one of: android-14, android-9, android-8, android-14, android-5
              # android-4, or android-3. You can't set it to the latest (for
              # example, API-17) because the NDK does not supply the platform. At
              # Android 5.0, there will likely be another platform added (android-22?).
              # This value is always used.
              # _ANDROID_API="android-14"
              _ANDROID_API="android-24"
              # _ANDROID_API="android-19"
              
              #####################################################################
              
              # If the user did not specify the NDK location, try and pick it up.
              # We expect something like ANDROID_NDK_ROOT=/opt/android-ndk-r8e
              # or ANDROID_NDK_ROOT=/usr/local/android-ndk-r8e.
              
              if [ -z "$ANDROID_NDK_ROOT" ]; then
              
                _ANDROID_NDK_ROOT=""
                if [ -z "$_ANDROID_NDK_ROOT" ] && [ -d "/usr/local/$_ANDROID_NDK" ]; then
                  _ANDROID_NDK_ROOT="/usr/local/$_ANDROID_NDK"
                fi
              
                if [ -z "$_ANDROID_NDK_ROOT" ] && [ -d "/opt/$_ANDROID_NDK" ]; then
                  _ANDROID_NDK_ROOT="/opt/$_ANDROID_NDK"
                fi
              
                if [ -z "$_ANDROID_NDK_ROOT" ] && [ -d "$HOME/$_ANDROID_NDK" ]; then
                  _ANDROID_NDK_ROOT="$HOME/$_ANDROID_NDK"
                fi
              
                if [ -z "$_ANDROID_NDK_ROOT" ] && [ -d "$PWD/$_ANDROID_NDK" ]; then
                  _ANDROID_NDK_ROOT="$PWD/$_ANDROID_NDK"
                fi
              
                # If a path was set, then export it
                if [ ! -z "$_ANDROID_NDK_ROOT" ] && [ -d "$_ANDROID_NDK_ROOT" ]; then
                  export ANDROID_NDK_ROOT="$_ANDROID_NDK_ROOT"
                fi
              fi
              
              # Error checking
              # ANDROID_NDK_ROOT should always be set by the user (even when not running this script)
              # http://groups.google.com/group/android-ndk/browse_thread/thread/a998e139aca71d77
              if [ -z "$ANDROID_NDK_ROOT" ] || [ ! -d "$ANDROID_NDK_ROOT" ]; then
                echo "Error: ANDROID_NDK_ROOT is not a valid path. Please edit this script."
                # echo "$ANDROID_NDK_ROOT"
                # exit 1
              fi
              
              # Error checking
              if [ ! -d "$ANDROID_NDK_ROOT/toolchains" ]; then
                echo "Error: ANDROID_NDK_ROOT/toolchains is not a valid path. Please edit this script."
                # echo "$ANDROID_NDK_ROOT/toolchains"
                # exit 1
              fi
              
              # Error checking
              if [ ! -d "$ANDROID_NDK_ROOT/toolchains/$_ANDROID_EABI" ]; then
                echo "Error: ANDROID_EABI is not a valid path. Please edit this script."
                # echo "$ANDROID_NDK_ROOT/toolchains/$_ANDROID_EABI"
                # exit 1
              fi
              
              #####################################################################
              
              # Based on ANDROID_NDK_ROOT, try and pick up the required toolchain. We expect something like:
              # /opt/android-ndk-r83/toolchains/arm-linux-androideabi-4.7/prebuilt/linux-x86_64/bin
              # Once we locate the toolchain, we add it to the PATH. Note: this is the 'hard way' of
              # doing things according to the NDK documentation for Ice Cream Sandwich.
              # https://android.googlesource.com/platform/ndk/+/ics-mr0/docs/STANDALONE-TOOLCHAIN.html
              
              ANDROID_TOOLCHAIN=""
              for host in "linux-x86_64" "linux-x86" "darwin-x86_64" "darwin-x86" "windows-x86_64"
              do
                if [ -d "$ANDROID_NDK_ROOT/toolchains/$_ANDROID_EABI/prebuilt/$host/bin" ]; then
                  ANDROID_TOOLCHAIN="$ANDROID_NDK_ROOT/toolchains/$_ANDROID_EABI/prebuilt/$host/bin"
                  break
                fi
              done
              
              # Error checking
              if [ -z "$ANDROID_TOOLCHAIN" ] || [ ! -d "$ANDROID_TOOLCHAIN" ]; then
                echo "Error: ANDROID_TOOLCHAIN is not valid. Please edit this script."
                # echo "$ANDROID_TOOLCHAIN"
                # exit 1
              fi
              
              case $_ANDROID_ARCH in
              	arch-arm)	  
                    ANDROID_TOOLS="arm-linux-androideabi-gcc arm-linux-androideabi-ranlib arm-linux-androideabi-ld"
              	  ;;
              	arch-x86)	  
                    ANDROID_TOOLS="i686-linux-android-gcc i686-linux-android-ranlib i686-linux-android-ld"
              	  ;;	  
              	*)
              	  echo "ERROR ERROR ERROR"
              	  ;;
              esac
              
              for tool in $ANDROID_TOOLS
              do
                # Error checking
                if [ ! -e "$ANDROID_TOOLCHAIN/$tool" ]; then
                  echo "Error: Failed to find $tool. Please edit this script."
                  # echo "$ANDROID_TOOLCHAIN/$tool"
                  # exit 1
                fi
              done
              
              # Only modify/export PATH if ANDROID_TOOLCHAIN good
              if [ ! -z "$ANDROID_TOOLCHAIN" ]; then
                export ANDROID_TOOLCHAIN="$ANDROID_TOOLCHAIN"
                export PATH="$ANDROID_TOOLCHAIN":"$PATH"
              fi
              
              #####################################################################
              
              # For the Android SYSROOT. Can be used on the command line with --sysroot
              # https://android.googlesource.com/platform/ndk/+/ics-mr0/docs/STANDALONE-TOOLCHAIN.html
              export ANDROID_SYSROOT="$ANDROID_NDK_ROOT/platforms/$_ANDROID_API/$_ANDROID_ARCH"
              export CROSS_SYSROOT="$ANDROID_SYSROOT"
              export NDK_SYSROOT="$ANDROID_SYSROOT"
              
              # Error checking
              if [ -z "$ANDROID_SYSROOT" ] || [ ! -d "$ANDROID_SYSROOT" ]; then
                echo "Error: ANDROID_SYSROOT is not valid. Please edit this script."
                # echo "$ANDROID_SYSROOT"
                # exit 1
              fi
              
              #####################################################################
              
              # If the user did not specify the FIPS_SIG location, try and pick it up
              # If the user specified a bad location, then try and pick it up too.
              #if [ -z "$FIPS_SIG" ] || [ ! -e "$FIPS_SIG" ]; then
              #
              #  # Try and locate it
              #  _FIPS_SIG=""
              #  if [ -d "/usr/local/ssl/$_ANDROID_API" ]; then
              #    _FIPS_SIG=`find "/usr/local/ssl/$_ANDROID_API" -name incore`
              #  fi
              #
              #  if [ ! -e "$_FIPS_SIG" ]; then
              #    _FIPS_SIG=`find $PWD -name incore`
              #  fi
              #
              #  # If a path was set, then export it
              #  if [ ! -z "$_FIPS_SIG" ] && [ -e "$_FIPS_SIG" ]; then
              #    export FIPS_SIG="$_FIPS_SIG"
              #  fi
              #fi
              
              ## Error checking. Its OK to ignore this if you are *not* building for FIPS
              #if [ -z "$FIPS_SIG" ] || [ ! -e "$FIPS_SIG" ]; then
              #  echo "Error: FIPS_SIG does not specify incore module. Please edit this script."
              #  # echo "$FIPS_SIG"
              #  # exit 1
              #fi
              
              #####################################################################
              
              # Most of these should be OK (MACHINE, SYSTEM, ARCH). RELEASE is ignored.
              export MACHINE=armv7
              export RELEASE=2.6.37
              export SYSTEM=android
              export ARCH=arm
              export CROSS_COMPILE="arm-linux-androideabi-"
              
              if [ "$_ANDROID_ARCH" == "arch-x86" ]; then
              	export MACHINE=i686
              	export RELEASE=2.6.37
              	export SYSTEM=android
              	export ARCH=x86
              	export CROSS_COMPILE="i686-linux-android-"
              fi
              
              # For the Android toolchain
              # https://android.googlesource.com/platform/ndk/+/ics-mr0/docs/STANDALONE-TOOLCHAIN.html
              export ANDROID_SYSROOT="$ANDROID_NDK_ROOT/platforms/$_ANDROID_API/$_ANDROID_ARCH"
              export SYSROOT="$ANDROID_SYSROOT"
              export NDK_SYSROOT="$ANDROID_SYSROOT"
              export ANDROID_NDK_SYSROOT="$ANDROID_SYSROOT"
              export ANDROID_API="$_ANDROID_API"
              
              # CROSS_COMPILE and ANDROID_DEV are DFW (Don't Fiddle With). Its used by OpenSSL build system.
              # export CROSS_COMPILE="arm-linux-androideabi-"
              export ANDROID_DEV="$ANDROID_NDK_ROOT/platforms/$_ANDROID_API/$_ANDROID_ARCH/usr"
              export HOSTCC=gcc
              
              VERBOSE=1
              if [ ! -z "$VERBOSE" ] && [ "$VERBOSE" != "0" ]; then
                echo "ANDROID_NDK_ROOT: $ANDROID_NDK_ROOT"
                echo "ANDROID_ARCH: $_ANDROID_ARCH"
                echo "ANDROID_EABI: $_ANDROID_EABI"
                echo "ANDROID_API: $ANDROID_API"
                echo "ANDROID_SYSROOT: $ANDROID_SYSROOT"
                echo "ANDROID_TOOLCHAIN: $ANDROID_TOOLCHAIN"
                echo "FIPS_SIG: $FIPS_SIG"
                echo "CROSS_COMPILE: $CROSS_COMPILE"
                echo "ANDROID_DEV: $ANDROID_DEV"
              fi
              
              1 Reply Last reply
              0

              2/6

              14 Jun 2019, 19:54

              topic:navigator.unread, 4
              • Login

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