Search code examples
androidandroid-ndkcross-compiling

Android ndk runtime - cannot locate symbol OPENSSL_init_ssl


I crosscompiled openssl 1.1.1g and i crosscompiled libcurl including the openssl. Crosscompilation went trough without a problem, no linker errors on libcurl nothing.

Then i included these two openssl and libcurl into my application where again no linking errors. But runtime shows this:

D/dalvikvm( 4018): Trying to load lib /data/app-lib/com.app-1/libnative-lib-logger.so 0x419cbc60
E/dalvikvm( 4018): dlopen("/data/app-lib/com.app-1/libnative-lib-logger.so") failed: dlopen failed: could not load library "libcurl.so" needed by "libnative-lib-logger.so"; caused by cannot locate symbol "OPENSSL_init_ssl" referenced by "libcurl.so"...

Update:

The library libnative-lib-logger.so is loaded via System.loadlibrary

CMakeFiles compiles the native-lib-logger and links with libraries libcrypto, libssl,libcurl, libz,...

This all worked in openssl 1.0.2 but using the 1.1.1g i come to this error.

Reverted to older libs (openssl, curl):

D/dalvikvm( 4526): Trying to load lib /data/app-lib/com.app-1/libnative-lib-logger.so 0x419c1010
D/dalvikvm( 4526): Added shared lib /data/app-lib/com.app-1/libnative-lib-logger.so 0x419c1010

Building of openssl: https://pastebin.com/tnNfvw7z Building of libcurl: https://pastebin.com/wQ5md83f

Sorry for the pastebin but scripts are not small.

I have no idea what to look for anymore :S All the help would be verrrry appriciated!


Solution

  • Mixing openssl versions is unlikely to work. on your case you are loading libcurl built against openssl 1.1.1 headers but old libssl is either already loaded or it is beign loaded at runtime. Remember, it is flat symbol namespace, having two libraries with the same symbol names is at best going to crash or at worst do something incredible nasty, on this case, with your crypto, which is a highly undesirable outcome.