Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Openssl Build Issue with Android NDK r8

I am trying to build Openssl inside my NDK app . I am constantly getting linking error even after following all necessary steps expected by Android ndk build. I am using ndk-build command with ndk supported library. i could see libcrypto.So bieng compiled and linked successfully

Compile thumb  : crypto <= sha512-armv4.S
SharedLibrary  : libcrypto.so
Install        : libcrypto.so => /Users/<me>/Downloads/paddybyers-openssl-android-2b40b8b/libs/armeabi/libcrypto.so

but openssl which starts after this is failing for some reason .I tried on all possible ways including building on eclipse as well as on command line.I even tried to build the openssl seperately as a stand alone project. But it always stops at the same level.

  • My configuration :

Using mac OS x NDK r8 Openssl source from : https://github.com/eighthave/openssl-android.git (I tried building on guardproject https://github.com/guardianproject/openssl-android.git )

it is throwing an error before it starts compiling openssl after creating libcrypto.So

****Compile thumb  : ssl <= ssl_algs.c
Compile thumb  : ssl <= bio_ssl.c
Compile thumb  : ssl <= ssl_err.c
Compile thumb  : ssl <= kssl.c
SharedLibrary  : libssl.so
Executable     : openssl
/Users/me/Documents/android/android-ndk/toolchains/arm-linux-androideabi-4.6/prebuilt/darwin-x86/bin/../lib/gcc/arm-linux-androideabi/4.6.x-google/../../../../arm-linux-androideabi/bin/ld: warning: libz.so, needed by ./obj/local/armeabi/libcrypto.so, not found (try using -rpath or -rpath-link)
./obj/local/armeabi/libcrypto.so: undefined reference to `zError'
./obj/local/armeabi/libcrypto.so: undefined reference to `inflateEnd'
./obj/local/armeabi/libcrypto.so: undefined reference to `deflate'
./obj/local/armeabi/libcrypto.so: undefined reference to `deflateInit_'
./obj/local/armeabi/libcrypto.so: undefined reference to `inflate'
./obj/local/armeabi/libcrypto.so: undefined reference to `deflateEnd'
./obj/local/armeabi/libcrypto.so: undefined reference to `inflateInit_'
collect2: ld returned 1 exit status
make: *** [obj/local/armeabi/openssl] Error 1**** }

I would really appreciate if some one help me out on this ?

like image 477
rana Avatar asked Feb 03 '26 13:02

rana


1 Answers

I ran into the same issue and fixed it by modifying OpenSSL1.0.1cForAndroid/crypto/Android.mk, adding libzib to the export list:

crypto/Android.mk
LOCAL_EXPORT_LDLIBS := -lz 

Crypto/Android.mk does have "LOCAL_LDLIBS += -lz" and so it successfully links it when building libcrypto but apparently it's not enough to propagate it to when linking in ssl (?).

I'm using ndk r8b, gcc 4.6

like image 100
minsk Avatar answered Feb 06 '26 04:02

minsk