Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Building OpenSSL for Android (ARMv7) on Win32

How can I build OpenSSL for Android ARM v7 (using Android NDK) on Win32?

like image 567
Ilya Avatar asked Aug 13 '14 17:08

Ilya


1 Answers

Until the OpenSSL's wiki and setenv-android.sh are updated accordingly, I'll publish the recipe here. The required fixes to the process are:

  1. Update setenv-android.sh to support Windows.
  2. Update PATH to use Android NDK's (mingw) GNU make (rather than Cygwin's).
  3. Invoke make with a Windows-style path to Cygwin's perl.

This recipe will be a strange hybrid of Cygwin and mingw (since Android NDK gcc toolchains for win32 are mingw). I'm assuming a Windows x86_64 build of the Android NDK unpacked into c:\android-ndk-r9d, and that you wish to use a gcc 4.8 toolchain.

  1. Install Android NDK (duh!).
  2. Install Cygwin -- make sure to include perl
  3. Start Cygwin shell as an administrator to make sure native symlinks will work.

Within the console, run the following script to set the variables:

export \
  CYGWIN=winsymlinks:native \
  ANDROID_API=android-14 \
  ANDROID_DEV=c:/android-ndk-r9d/platforms/android-14/arch-arm/usr \
  PATH=/cygdrive/c/android-ndk-r9d/prebuilt/windows-x86_64/bin:/cygdrive/c/android-ndk-r9d/toolchains/arm-linux-androideabi-4.8/prebuilt/windows-x86_64/bin:$PATH \
  MACHINE=armv7 \
  SYSTEM=android \
  ARCH=arm \
  CROSS_COMPILE=arm-linux-androideabi-

Now, unpack openssl:

  1. tar xzfv openssl-1.0.1i.tar.gz (or whatever your tarball is)
  2. cd openssl-1.0.1i (or whatever your version is)

Make sure you have actual native Win32 (!) symlinks in include/openssl:

cmd /c "dir include\openssl"

You should see something like:

13-Aug-14  05:59 PM    <SYMLINK>      aes.h [..\..\crypto\aes\aes.h]
13-Aug-14  05:59 PM    <SYMLINK>      asn1.h [..\..\crypto\asn1\asn1.h]

(etc.)

Now it's time to configure:

./config shared -no-ssl2 -no-ssl3 -no-comp -no-hw -no-engine --openssldir=/foo/bar

Ignore the failure to build (due to failure to find perl). We'll rectify this right away. Do this:

make PERL=$(cygpath -w $(which perl))

Now wait for a few minutes until it builds, and presto, you have your libcrypto.so etc.

like image 96
Ilya Avatar answered Oct 15 '22 12:10

Ilya