5

I created an application for android which uses native code.

It needs the libcrypto.a library from OpenSSL, I don't remember where I downloaded it, but it works. The problem is that the version of the lib is 1.0.0a and I want to update to the latest (now v1.0.1e). I downloaded https://github.com/android/platform_external_openssl and tried to compile it, but there are a lot of errors while compiling. I don't know how to generate the lib.

Or maybe the c and h files (from http://www.openssl.org/source/) can be included in my c&h files and not use the lib?

Thanks!

JoniJnm
  • 720
  • 2
  • 10
  • 19
  • I know, this is not an answer to your question, but you could use spongycastle library (http://rtyley.github.io/spongycastle/) as an alternative. It does not need NDK and it works. – Analizer May 29 '13 at 09:33

2 Answers2

12

If you don't want to compile the libs yourself I have just done this and uploaded to github.

Version 1.0.2 (22 Jan 2015) of OpenSSL

It includes static and shared libraries for Arm and x86, also include Android.mk and include files.

https://github.com/emileb/OpenSSL-for-Android-Prebuilt

Emile Belanger
  • 139
  • 1
  • 4
  • 2
    I'm trying to build openssl static lib myself but having some issues. Would you be able to share the build script which I can refer to find the issue? – pree Mar 23 '16 at 00:47
  • From July 11, 2016 Google play blocks application with older version of OpenSSL. You must use OpenSSL 1.02f/1.01r or higher. – Libor B. Jul 14 '16 at 06:16
9

Using the latest OpenSSL sources you should be able to use the standalone toolchain from the Android NDK and configure + make. The basic steps are:

  1. export TOOL_PREFIX, CC and SYSROOT to point at appropriate toolchain paths
  2. Configure
  3. make

A couple of examples:

ARMv5te:

CC="/path/to/arm-linux-androideabi-gcc -mtune=xscale -march=armv5te -msoft-float --sysroot=/ndk_path/platforms/android-9/arch-arm"
./Configure android no-asm

ARMv7:

CC="/path/to/arm-linux-androideabi-gcc -march=armv7-a -mfloat-abi=softfp --sysroot=/ndk_path/platforms/android-9/arch-arm"
./Configure android-armv7 no-asm
NuSkooler
  • 5,391
  • 1
  • 34
  • 58
  • Hi, thanks. But can it be done with Windows? I will create a VM to try your example :) – JoniJnm May 30 '13 at 15:39
  • I don't currently do Android development on Windows. If you can fulfill the requirements for Configure and friends (e.g. via Cygwin/UNIX like env) it should be fine. – NuSkooler May 30 '13 at 15:51
  • With linux it works, thanks. But not with armv7, it throws this error: cryptlib.c:1:0: error: valor erróneo (armv7-a) para -march= switch – JoniJnm May 31 '13 at 10:19
  • Are you using the ARMv7a standalone toolchain (It does differ from the ARMv5). If I remember correctly (I cannot check at this moment) when you run the script to generate the toolchain you must supply a parameter to do this. – NuSkooler May 31 '13 at 19:42
  • 1
    JoniJnm - "But can it be done with Windows?" - OpenSSL's Android cross compile script can probably be run under MinGW. – jww Jan 17 '14 at 17:08
  • What about `x86`? – Toochka Aug 07 '17 at 07:50