Wednesday, April 25, 2018

Building openssl for libindy and Android

Building of the indy-sdk for Android is currently not supported out of the box. The underlying issue is that libindy is implemented in Rust and the Android platform is currently not supported.

To build openssl for Android on your Ubuntu system take the following steps:
  1. Setup your build environment - missing tools are likely to be noticed by "configure" so you can install them then 
  2. Download openssl (I used version 1.0.2n) and unpack it.
  3. Setup the Android toolchain (command line tools are enough) and NDK toolchain for e.g. arm
    ${NDK_HOME}/build/tools/  --api 14 --arch arm  --install-dir ${NDK_TOOLCHAIN_DIR}/arm --stl=libc++
    or for arm64
    ${NDK_HOME}/build/tools/  --api 21 --arch arm64  --install-dir ${NDK_TOOLCHAIN_DIR}/arm64 --stl=libc++
  4. Edit the script

    I have these values:
  5. Run the script '.'
  6. run this:
    ./config shared no-ssl2 no-ssl3 no-comp no-hw no-engine      --openssldir=/usr/local/ssl/arm/$ANDROID_API --prefix=/usr/local/ssl/arm/$ANDROID_API
  7. Edit Makefile and add
    to CFLAG and DEPFLAG
    Remove -mandroid where it occurs
  8. Run make. This creates the libraries in the current directory
    make build_libs
  9. Make install fails because the application openssl is not build for Android.
    So put a comment # in front of the install command.
    "#@set -e; target=install; $(RECURSIVE_BUILD_CMD)" in the target "install_sw". "make install" now installs the include files and the libs.
The include files are needed to compile libindy. The libraries need to be put into a place where the Rust build system can find them.