Building OpenSSL 1.1.1 for Android on Windows with the Visual Studio 2017 native toolchain and cygwin
Disclaimer: The build scripts outlined in this post have been created in my own spare time. The license of the code is the same license as is used for OpenSSL.
A while ago I wrote about Building OpenSSL 1.0.2 for Android on Windows with Visual Studio 2017, and also how to build OpenSSL 1.1.1 for iOS/iPadOS. This time, I will show how to build OpenSSL 1.1.1 for Android on Windows with the Visual Studio 2017 native toolchain and cygwin.
The procedure outlined here produces actually working static or dynamic libraries and has the same prerequisites as in the article before on how to build version 1.0.2 of the libraries, but with one addition: The cygwin install will also require the installation of gnu make and patch.
Using the scripts
In order to use the scripts I have written, follow theses steps:
- Make sure all preconditions are fulfilled, as described above (cygwin with make and patch) and in the article on building version 1.0.2
- Unpack the zip File (Download) into a writable directory, make sure that you have the "Change permissions" right for the directory and all its files and subdirectories granted, otherwise the calls to chmod in the build scripts will fail (cygwin places some strange NULL SID ACEs into the DACL of files that are granted execution right using chmod which requires the "Change permissions" access right)
- Download openssl-1.1.1l.tar.gz from openssl.org (Download) and copy it into the directory created in the previous step.
- Open a windows command prompt and change the current directory to the directory from the above steps
- Execute "build.bat" and wait
- Find the header files or the build under platform specific subdirectories like arch-x86, arch-arm in the subdirectory openssl-1.1.1l/include and find the libraries (libcrypto.a, libssl.a, libcrypto.so and libssl.so) directly in the subdirectory openssl-1.1.1l.
OPENSSLNAME=openssl-1.1.1l
#
# in order to build with dynamic libraries (i.e. libcrypto.so and libssl.so in addition to
# only libcrypto.a and libssl.a, remove the -no-shared flag from the following command line:
#
perl Configure $SSL_TARGET $OPTIONS $ADD_CFLAGS -I$NDK_PATH/sysroot/usr/include/$TRIBLE $ADD_LIB_FLAGS -no-shared
/usr/bin/make