openSSL using Android's NDK problems -


i have following situation, porting piece of app using openssl aes encryption, have compile, linker fails. situation following: 1. wrote jni wrapper :

private native string cipherstring(string plaindata, int datasize, string password, int passsize); private native string decipherstring(string ciphereddata, int datasize, string password, int passsize); 

next have c++ file call has proper jni sintax translates jstring char * , other needed transformations, , makes call cpp file imports openssl headers (present , accounted for) , calls openssl methods ciphering , deciphering.

so when call ndk-build, builds thumbs, compiler compiles them correctly. next needed port openssl android, , used openssl android works char simple ndk-build (in root of project, ofcourse) , builds libssl.so , libcrypto.so

so need connect two.. find challenge connect build scripts, 1 ndk-build compiles , linkes (i appreciate simple example project if has time it)

so copied compiled libssl , libcrypto .so files in jni/includes/prebuilt , want include them in project linker able create lib use @ end.

i have following android.mk file

local_path := $(call my-dir) include $(clear_vars) include $(local_path)/includes/build/common.mk include $(local_path)/includes/build/common_includes.mk app_stl := gnustl_static  local_module    := packer local_src_files := modules/cipher/wrapper.cpp \                     ... #rest of cpp code  local_c_includes += $(local_path)/includes/openssl  local_shared_libraries := $(local_path)/includes/precompiled/libssl.so \             $(local_path)/includes/precompiled/libcrypto.so  local_shared_modules := sslx cryptox include $(build_shared_library)  local_path := $(call my-dir) include $(clear_vars) local_module := sslx local_src_files := $(local_path)/includes/precompiled/libssh.so include $(prebuilt_shared_library)  local_path := $(call my-dir) include $(clear_vars) local_module := cryptox local_src_files := $(local_path)/includes/precompiled/libssh.so include $(prebuilt_shared_library) 

and when calling ndk-build dissapointing

sslx: local_src_files points missing file. check /home/user/development/tools/sdk/android/ndk/build/core//home/user/development/tools/sdk/android/ndk/build/core/includes/precompiled/libssh.so exists  or path correct. aborting    .  stop. 

as can guess path totally wrong, , confuses me ${local_path} returns correct path first batch of includes , wrong 1 .so files ... appreciated!

here solution, updated ndk8c

step zero: download , fix android ndk dunno how ndk has interesting flaw, (in oppinion) doesn't allow compile lot's of stuff, able compile openssl need make small fix, extract ndk8c whereever keep tools, , edit file : android-ndk-r8c/build/gmsl/__gmsl line 512 : change line

int_encode = $(__gmsl_tr1)$(wordlist 1,$1,$(__gmsl_input_int)) 

with line

int_encode = $(__gmsl_tr1)$(wordlist 1,$(words $1),$(__gmsl_input_int)) 

and you're go!

step one : download openssl , compile android : either compile ported version found here or download official 1.0.0c version of openssl , compile android using manual provided in github linked android compatible version

so next step libssl.so , libcrypto.so , put them in ndk folder easy access, copy them

openssl-folder/libs/armeabi/ 

to

android-ndk-r8c/platforms/android-8/arch-arm/usr/lib 

this way when compiling can include libs using simple linker switch -lssl -lcrypto

step two : curl's latest source here

open file in docs/install , follow steps needed make standalone toolchain , put in desired folder, , tricky part, needed have android's source code config continue, though have standalone compiled openssl can include header files there too, in anycase more complicated version choose do, did not choose evade them can go google aosp site , go trough steps build , initialize environment.

so :

1.download,

  1. go root of source code , run :

    ~: build/envsetup.sh; lunch 1; make;

so need compile curl ssl support, so,

step three

extract curl desired folder (i have specific desire of disabling except http/s keep library small possible meaning ~300k, if want more protocols in lib, remove --disable-protocol desired protocol) run following :

make clean  export path=/opt/arm-linux-androideabi-4.4.3/bin:$path  export ldflags="\ -lssl \ -lcrypto \ -l/home/user/development/tools/sdk/android/ndk/platforms/android-8/arch-arm/usr/lib"  export cflags="\ -i/home/user/development/aosp/2.3.7/system/core/include \ -i/home/user/development/tools/sdk/android/ndk/platforms/android-8/arch-arm/usr/include"  ./configure --host=arm-linux-androideabi \ --with-ssl=/home/user/development/projects/portinglibs/openssl-android-master \ --disable-ftp \ --disable-gopher \ --disable-file \ --disable-imap \ --disable-ldap \ --disable-ldaps \ --disable-pop3 \ --disable-proxy \ --disable-rtsp \ --disable-smtp \ --disable-telnet \ --disable-tftp \ --without-gnutls \ --without-libidn \ --without-librtmp \ --disable-dict   make    note in block above, if don't want use aosp source, switch   -i/home/user/development/aosp/2.3.7/system/core/include \  include folder ssl distribution. 

so have : static :

curl-7.28.1/lib/.libs/libcurl.a 

and shared :

curl-7.28.1/lib/.libs/libcurl.so.5.3 

so that's it.. take file, , compile away :)


Comments

Popular posts from this blog

monitor web browser programmatically in Android? -

Shrink a YouTube video to responsive width -

wpf - PdfWriter.GetInstance throws System.NullReferenceException -