Building external/openssl

2,023 views
Skip to first unread message

phrakture

unread,
Oct 14, 2010, 5:42:01 PM10/14/10
to android-ndk
Hello all,

I would like to build the openssl sources from the android platform
with the NDK.

http://android.git.kernel.org/?p=platform/external/openssl.git;a=summary

But I can't seem to accomplish this. After adding an Application.mk
file, there are many compilation issues.

Am I missing some piece of this puzzle? Do I need the entire Android
platform to build one library? Is there any other way to link against
the official Android openssl libs?

Cheers,
Aaron

Timmmm

unread,
Nov 4, 2010, 11:49:30 AM11/4/10
to android-ndk
I would also like to know this. The NDK doesn't seem set up to allow
it easily but it should be possible. How far did you get?

Timmmm

unread,
Nov 5, 2010, 1:45:04 PM11/5/10
to android-ndk
On Nov 4, 3:49 pm, Timmmm <tdh...@gmail.com> wrote:
> On Oct 14, 9:42 pm, phrakture <aaronmgrif...@gmail.com> wrote:
>
> > Hello all,
>
> > I would like to build theopensslsources from the android platform
> > with the NDK.
>
> >http://android.git.kernel.org/?p=platform/external/openssl.git;a=summary
>
> > But I can't seem to accomplish this. After adding an Application.mk
> > file, there are many compilation issues.

I made a bit of progress and I think I will be able to get it to work.
You need to do this:

# Get the source.
git clone git://android.git.kernel.org/platform/external/openssl.git

# Go into the directory.
cd openssl

# Trick the NDK into thinking this is the project dir. This is the
easiest and only way I could find to do it.
touch AndroidManifest.xml

# Give the NDK build system the Application.mk it needs. I couldn't
find a way to specify this manually, and it seems the jni bit is
hardcoded.
mkdir jni

echo "APP_PROJECT_PATH := $(pwd)" >> jni/Application.mk
echo "APP_BUILD_SCRIPT := $(APP_PROJECT_PATH)/Android.mk" >> jni/
Application.mk

# Edit crypto/Android to fix the include paths.
nano crypto/Android.mk

# Change the last bits to:
#################
LOCAL_C_INCLUDES += \
$(NDK_PROJECT_PATH) \
$(NDK_PROJECT_PATH)/include
# external/zlib

# LOCAL_SHARED_LIBRARIES += libz

#ifneq ($(TARGET_SIMULATOR),true)
# LOCAL_SHARED_LIBRARIES += libdl
#endif

LOCAL_LDLIBS += -lz
# LOCAL_LDLIBS += -ldl
#################

Then it actually starts successfully compiling things, but gets stuck
at some assembly stuff.



Timmmm

unread,
Nov 5, 2010, 2:24:05 PM11/5/10
to android-ndk
Aha! I got it to work. Full instructions:

# Get the source.
git clone git://android.git.kernel.org/platform/external/openssl.git
# Go into the directory.
cd openssl
# Trick the NDK into thinking this is the project dir. This is the
easiest and only way I could find to do it.
touch AndroidManifest.xml
# Give the NDK build system the Application.mk it needs. I couldn't
find a way to specify this manually, and it seems the jni bit is
hardcoded.
mkdir jni
echo "APP_PROJECT_PATH := $(pwd)" >> jni/Application.mk
echo "APP_BUILD_SCRIPT := $(APP_PROJECT_PATH)/Android.mk" >> jni/
Application.mk
# Edit all the Android.mk's.
nano crypto/Android.mk
nano apps/Android.mk
nano ssl/Android.mk

# In all of them you need to replace "external/openssl" with "$
(NDK_PROJECT_PATH)". Also in
# crypto/Android.mk you need to comment out the assembly stuff so that
it always uses aes/aes_core.c
# Obviously you won't have any assembly optimisations then, but I
couldn't get them to work. :-/

# Finally run:
path/to/android-ndk-r4b/ndk-build -j2

# libcrypto.so and libssl.so are in
cd libs/armeabi

Guian

unread,
Nov 19, 2010, 9:59:20 AM11/19/10
to android-ndk
thanks, that really helps :)

Guian

unread,
Nov 19, 2010, 10:17:00 AM11/19/10
to android-ndk
hmm :/

I got some "undefined reference to `ENGINE_cleanup'"
errors at link stage...

I tried to ad engine.eng_lib.c to the crypto/Android.mk compiled files
but I got this :

#error ENGINE is disabled.
because OPENSSL_NO_ENGINE is defined

How can I enable 'ENGINE' so I could use ENGINE_cleanup ?





On 5 nov, 19:24, Timmmm <tdh...@gmail.com> wrote:
Reply all
Reply to author
Forward
0 new messages