Stack Exchange
Compile OpenSSL 1.1.0 for Android
I'm trying to compile openssl-1.1.0 on Android by cygwin follow by this guidance:
Compiling the latest OpenSSL for Android
But it's failed, this is the error :
crypto/aes/aes_ecb.c:10:20: fatal error: assert.h: No such file or directory
 #include <assert.h>

I'm using Android-ndk-r12b, Win10, cygwin 64 bit.
This is my pre-config before compiling:
export NDK=~/android-ndk-r12b
$NDK/build/tools/make-standalone-toolchain.sh --platform=android-21 --toolchain=arm-linux-androideabi-4.9 --install-dir=`pwd`/android-toolchain-arm
export TOOLCHAIN_PATH=`pwd`/android-toolchain-arm/bin
export TOOL=arm-linux-androideabi
export NDK_TOOLCHAIN_BASENAME=${TOOLCHAIN_PATH}/${TOOL}
export CC=$NDK_TOOLCHAIN_BASENAME-gcc
export CXX=$NDK_TOOLCHAIN_BASENAME-g++
export LINK=${CXX}
export LD=$NDK_TOOLCHAIN_BASENAME-ld
export AR=$NDK_TOOLCHAIN_BASENAME-ar
export RANLIB=$NDK_TOOLCHAIN_BASENAME-ranlib
export STRIP=$NDK_TOOLCHAIN_BASENAME-strip
export ARCH_FLAGS="-mthumb"
export ARCH_LINK=
export CPPFLAGS=" ${ARCH_FLAGS} -fpic -ffunction-sections -funwind-tables -fstack-protector -fno-strict-aliasing -finline-limit=64 "
export CXXFLAGS=" ${ARCH_FLAGS} -fpic -ffunction-sections -funwind-tables -fstack-protector -fno-strict-aliasing -finline-limit=64 -frtti -fexceptions "
export CFLAGS=" ${ARCH_FLAGS} -fpic -ffunction-sections -funwind-tables -fstack-protector -fno-strict-aliasing -finline-limit=64 "
export LDFLAGS=" ${ARCH_LINK} "
./Configure android
PATH=$TOOLCHAIN_PATH:$PATH make

Please help to tell me where I'm wrong
EDIT:
Follow by jww's suggestion, I try with https://wiki.openssl.org/index.php/Android
I changed some config in setenv-android.sh into:
-_ANDROID_NDK="android-ndk-r12b"
-_ANDROID_EABI="arm-linux-androideabi-4.9"
-_ANDROID_API="android-21"

To generate valid toolchains, I add "windows-x86_64" into 
for host in "linux-x86_64" "linux-x86" "darwin-x86_64" "darwin-x86"
Now it's:
for host in "linux-x86_64" "linux-x86" "darwin-x86_64" "darwin-x86" "windows-x86_64"
do
....
done

+Build openssl-1.1.0:
Error: 
$ perl -pi -e 's/install: all install_docs install_sw/install: install_docs install_sw/g' Makefile.org
Can't open Makefile.org: No such file or directory.

EDIT 2:
I follow the wiki update by jww and it runs smoothly until this command:
arm-linux-androideabi-gcc -I /usr/local/ssl/include my_prog.c -o my_prog.exe -L /usr/local/ssl/lib -lssl -lcrypto

If I use $ANDROID_TOOCHAIN/arm-linux-androideabi-gcc -I /usr/local/ssl/include my_prog.c -o my_prog.exe -L /usr/local/ssl/lib -lssl -lcrypto , it doesn't understand -I and my_prog.c
I want to build openssl-1.1.0 for android but I don't know how to fix it. Please help

One of the simpler ways is to follow the instructions detailed at OpenSSL and Android from the OpenSSL wiki. Is there a reason its not suitable for you?

I also tried compiling with setenv-android.sh but it's fail for openssl 1.1.0, that why I turn into this. Maybe I miss some config in setenv-android.sh, Thanks for your suggestion, I'll try again with that.

Does the build tell you the compiler command line for the failing command?

Yes, it tells me Can't open Makefile.org: No such file or directory when compiling this line:
$ perl -pi -e 's/install: all install_docs install_sw/install: install_docs install_sw/g' Makefile.org

@kairen - "Can't open Makefile.org" - It sounds like you are using OpenSSL 1.1.0. Skip that step; it only helps with the make install rule. Its not essential to the cross-compile build. I'll update the wiki soon.

@jww thanks, your wiki update will help alots

@jww I use android-ndk-r12b which only have "Window-x32-64" in Toolchains folder. In your setenv-android.sh, when setting ANDROID-TOOlCHAINS path, I see there is no window-x32-64 in line "for host in ....." , that makes toolchain path is empty on my environment, is it ok to add window-x32-64 to the loop "for host in...."?

@kairen - Yes, its OK. Send me the your changes, attribute them in setenv script, and I'll upload the new one for you. Or, you can request an account on the wiki and upload it.

@jww Thanks for your kind, I almost use the same config as in your setenv-android.sh, just change _ANDROID_NDK="android-ndk-r12b"
_ANDROID_EABI="arm-linux-androideabi-4.9" _ANDROID_API=21 and add "windows-x86_64" into for host in "linux-x86_64" "linux-x86" "darwin-x86_64" "darwin-x86" for valid ANDROID-TOOLCHAIN path. Is it enough to compile openssl 1.1.0 successfully ? And one thing, use "make depend" then "make all" will have same result with "make install" ?

I'm getting ther same behaviour even though I followed the wiki. Also the same behaviour for 1.0.1e

I was trying to build OpenSSL 1.1.0g for Android with
android NDK android-ndk-r16b, centOS 6.9 64 bit OS.

as per https://wiki.openssl.org/index.php/Android 
and had the same problem 
crypto/aes/aes_ecb.c:10:20: fatal error: assert.h: No such file or directory
 #include <assert.h>

After searching, I found that Updated NDK android-ndk-r16b has updated the sysroot to android-ndk-r16b/sysroot which contains the include directories but no library.
So the include path and the library path has changed
but the setenv-android.sh set the sysroot as
export ANDROID_SYSROOT="$ANDROID_NDK_ROOT/platforms/$_ANDROID_API/$_ANDROID_ARCH"

But this is valid for android-ndk-r13b
I can successfully build the OpenSSL with android-ndk-r13b.

I still see same issue

Please take a look at this Github library
setenv-android.sh is not necessary. This really works.

Hi can you please share steps ?I am facing error on 'make build' command
