...someplace, where there isn't any trouble? Do you suppose there is such a place, Toto?

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.
If you need some more information on how the build scripts work, please refer to my article on building OpenSSL 1.0.2, the very same basic principles apply here as well. In case you want to build a newer version of OpenSSL than version  1.1.1.l, all you have to do is change the reference to the name of the openssl tarball in buildplatform.sh in the following line:
By default the build scripts only build the static libraries libcrypto.a and libssl.a. If you want to create the dynamic libaries as well (i.e. libcrypto.so and libssl.so) locate the following lines in buildplatform.sh:
# 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
Follow the advise of the comment and remove the -no-shared flag, rebuild and you will also get the shared libraries.