To build openssl for Android on your Ubuntu system take the following steps:
- Setup your build environment - missing tools are likely to be noticed by "configure" so you can install them then
- Download openssl (I used version 1.0.2n) and unpack it.
- Setup the Android toolchain (command line tools are enough) and NDK toolchain for e.g. arm
${NDK_HOME}/build/tools/make_standalone_toolchain.py --api 14 --arch arm --install-dir ${NDK_TOOLCHAIN_DIR}/arm --stl=libc++
or for arm64
${NDK_HOME}/build/tools/make_standalone_toolchain.py --api 21 --arch arm64 --install-dir ${NDK_TOOLCHAIN_DIR}/arm64 --stl=libc++ - Edit the script setenv-android.sh
I have these values:
_ANDROID_NDK="android-ndk-r16"
_ANDROID_EABI="arm-linux-androideabi-4.9"
_ANDROID_ARCH=arch-arm
_ANDROID_API="android-14" - Run the script '. setenv-android.sh'
- 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 - Edit Makefile and add
"--sysroot=/home/ignisvulpis/NDK_TOOLCHAIN_DIR/arm/sysroot/"
to CFLAG and DEPFLAG
Remove -mandroid where it occurs - Run make. This creates the libraries in the current directory
make build_libs - 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.