android - Application crashes in loading C++ jni library dynamically linked with openss-1.0.1h -


i using c++ library. dynamically linked openss-1.0.1 h libraries(i.e libssl.so, libcrypto.so) , openssl libraries pre-built. problem when try load library using android application, application crashes. , in log cat can see reason -

"could not find libssl.so.1.0.0 needed libabc.so"

i haven't called system.loadlibrary() openssl libraries, called c++ library.

this issue never works when use dynamic linking of openssl-1.0.0 or static linking of openssl-1.0.1h.

i don't know how resolve issue. can 1 me regarding this?

i did following load library -

system.loadlibrary("ssl"); system.loadlibrary("crypto"); system.loadlibrary("abc"); 

it looks have 2 problems. first linking against openssl; , second finding library in apk.


i using c++ library, dynamically linked openss-1.0.1 h libraries...

here first problem. android's equivalent of init zygote. zygote loads platform's version of openssl. when zygote forks start app, app gets linked version of openssl, 0.9.8. since app built against 1.0.1, crash @ runtime because 0.9.8 , 1.0.0 not binary compatible.

to resolve this, have build wrapper shared object links against static version of openssl library. then, when need make openssl call, expose through wrapper. example, might have getsslcontext wraps calls openssl's sslv23_method, ssl_ctx_new, ssl_ctx_set_options, etc.

this avoids calling zygote's downlevel openssl. documented on openssl wiki @ openssl , android.


"could not find libssl.so.1.0.0 needed libabc.so"

here second problem. first, create wrapper shared object described above. second, place shared objects in proper directory. shared wrapper should placed in lib/ directory. believe can have specialized versions of library in subdirectories. example, lib/ generic fallback, while lib/armv7-a/ shared object built armv7a.

you can find libraries @ runtime applicationinfo class , nativelibdir method:

public string nativelibrarydir      full path directory native jni libraries stored. 

also see android's jni tips , native libraries section.


 system.loadlibrary("ssl");  system.loadlibrary("crypto"); 

related, libssl depends upon libcrypto, should be:

 static {      system.loadlibrary("crypto");      system.loadlibrary("ssl");  } 

but should avoid , use wrapper shared object.


Comments

Popular posts from this blog

google api - Incomplete response from Gmail API threads.list -

Installing Android SQLite Asset Helper -

Qt Creator - Searching files with Locator including folder -