I compiled both OpenSSL/1.1.1b and Curl/7.61.0 for Android. Both libraries are shared and they compile without issues. When running nm
and readelf
on the libraries I get the following outputs:
#
# Curl
#
❯ $NDK/toolchains/arm-linux-androideabi-4.9/prebuilt/darwin-x86_64/bin/arm-linux-androideabi-nm -D libcurl.so | rg EVP_MD_CTX_
U EVP_MD_CTX_free
U EVP_MD_CTX_new
❯ $NDK/toolchains/arm-linux-androideabi-4.9/prebuilt/darwin-x86_64/bin/arm-linux-androideabi-readelf -s app/src/main/jniLibs/armeabi-v7a/libcurl.so | rg EVP_MD_CTX_
70: 00000000 0 FUNC GLOBAL DEFAULT UND EVP_MD_CTX_new@OPENSSL_1_1_0 (3)
78: 00000000 0 FUNC GLOBAL DEFAULT UND EVP_MD_CTX_free@OPENSSL_1_1_0 (3)
1793: 00000000 0 FUNC GLOBAL DEFAULT UND EVP_MD_CTX_new
1801: 00000000 0 FUNC GLOBAL DEFAULT UND EVP_MD_CTX_free
#
# Crypto
#
❯ $NDK/toolchains/arm-linux-androideabi-4.9/prebuilt/darwin-x86_64/bin/arm-linux-androideabi-nm -D libcrypto.so | rg EVP_MD_CTX_
00129e14 T EVP_MD_CTX_clear_flags
0011d080 T EVP_MD_CTX_copy
0011ceec T EVP_MD_CTX_copy_ex
0011d130 T EVP_MD_CTX_ctrl
0011cbb0 T EVP_MD_CTX_free
00129dd8 T EVP_MD_CTX_md
00129dec T EVP_MD_CTX_md_data
0011cb98 T EVP_MD_CTX_new
00129de4 T EVP_MD_CTX_pkey_ctx
0011cac0 T EVP_MD_CTX_reset
00129e04 T EVP_MD_CTX_set_flags
00129e30 T EVP_MD_CTX_set_pkey_ctx
00129dfc T EVP_MD_CTX_set_update_fn
00129e24 T EVP_MD_CTX_test_flags
00129df4 T EVP_MD_CTX_update_fn
❯ $NDK/toolchains/arm-linux-androideabi-4.9/prebuilt/darwin-x86_64/bin/arm-linux-androideabi-readelf -s app/src/main/jniLibs/armeabi-v7a/libcrypto.so | rg EVP_MD_CTX_
170: 0011cb98 24 FUNC GLOBAL DEFAULT 11 EVP_MD_CTX_new@@OPENSSL_1_1_0
172: 00129de4 8 FUNC GLOBAL DEFAULT 11 EVP_MD_CTX_pkey_ctx@@OPENSSL_1_1_0
174: 00129dd8 12 FUNC GLOBAL DEFAULT 11 EVP_MD_CTX_md@@OPENSSL_1_1_0
177: 0011cbb0 40 FUNC GLOBAL DEFAULT 11 EVP_MD_CTX_free@@OPENSSL_1_1_0
956: 00129dec 8 FUNC GLOBAL DEFAULT 11 EVP_MD_CTX_md_data@@OPENSSL_1_1_0
1166: 00129e04 16 FUNC GLOBAL DEFAULT 11 EVP_MD_CTX_set_flags@@OPENSSL_1_1_0
1168: 00129dfc 8 FUNC GLOBAL DEFAULT 11 EVP_MD_CTX_set_update_fn@@OPENSSL_1_1_0
1307: 0011ceec 404 FUNC GLOBAL DEFAULT 11 EVP_MD_CTX_copy_ex@@OPENSSL_1_1_0
1344: 0011cac0 216 FUNC GLOBAL DEFAULT 11 EVP_MD_CTX_reset@@OPENSSL_1_1_0
2127: 00129e30 76 FUNC GLOBAL DEFAULT 11 EVP_MD_CTX_set_pkey_ctx@@OPENSSL_1_1_1
2150: 00129e24 12 FUNC GLOBAL DEFAULT 11 EVP_MD_CTX_test_flags@@OPENSSL_1_1_0
2159: 00129e14 16 FUNC GLOBAL DEFAULT 11 EVP_MD_CTX_clear_flags@@OPENSSL_1_1_0
2164: 0011d130 56 FUNC GLOBAL DEFAULT 11 EVP_MD_CTX_ctrl@@OPENSSL_1_1_0
2165: 0011d080 32 FUNC GLOBAL DEFAULT 11 EVP_MD_CTX_copy@@OPENSSL_1_1_0
2276: 00129df4 8 FUNC GLOBAL DEFAULT 11 EVP_MD_CTX_update_fn@@OPENSSL_1_1_0
11007: 0011cb98 24 FUNC GLOBAL DEFAULT 11 EVP_MD_CTX_new
11009: 00129de4 8 FUNC GLOBAL DEFAULT 11 EVP_MD_CTX_pkey_ctx
11011: 00129dd8 12 FUNC GLOBAL DEFAULT 11 EVP_MD_CTX_md
11014: 0011cbb0 40 FUNC GLOBAL DEFAULT 11 EVP_MD_CTX_free
11793: 00129dec 8 FUNC GLOBAL DEFAULT 11 EVP_MD_CTX_md_data
12003: 00129e04 16 FUNC GLOBAL DEFAULT 11 EVP_MD_CTX_set_flags
12005: 00129dfc 8 FUNC GLOBAL DEFAULT 11 EVP_MD_CTX_set_update_fn
12144: 0011ceec 404 FUNC GLOBAL DEFAULT 11 EVP_MD_CTX_copy_ex
12181: 0011cac0 216 FUNC GLOBAL DEFAULT 11 EVP_MD_CTX_reset
12964: 00129e30 76 FUNC GLOBAL DEFAULT 11 EVP_MD_CTX_set_pkey_ctx
12987: 00129e24 12 FUNC GLOBAL DEFAULT 11 EVP_MD_CTX_test_flags
12996: 00129e14 16 FUNC GLOBAL DEFAULT 11 EVP_MD_CTX_clear_flags
13001: 0011d130 56 FUNC GLOBAL DEFAULT 11 EVP_MD_CTX_ctrl
13002: 0011d080 32 FUNC GLOBAL DEFAULT 11 EVP_MD_CTX_copy
13113: 00129df4 8 FUNC GLOBAL DEFAULT 11 EVP_MD_CTX_update_fn
#
# SSL
#
❯ $NDK/toolchains/arm-linux-androideabi-4.9/prebuilt/darwin-x86_64/bin/arm-linux-androideabi-nm -D libssl.so | rg EVP_MD_CTX_
U EVP_MD_CTX_copy
U EVP_MD_CTX_copy_ex
U EVP_MD_CTX_ctrl
U EVP_MD_CTX_free
U EVP_MD_CTX_md
U EVP_MD_CTX_new
U EVP_MD_CTX_set_flags
❯ $NDK/toolchains/arm-linux-androideabi-4.9/prebuilt/darwin-x86_64/bin/arm-linux-androideabi-readelf -s libssl.so | rg EVP_MD_CTX_
115: 00000000 0 FUNC GLOBAL DEFAULT UND EVP_MD_CTX_md@OPENSSL_1_1_0 (6)
124: 00000000 0 FUNC GLOBAL DEFAULT UND EVP_MD_CTX_copy@OPENSSL_1_1_0 (6)
125: 00000000 0 FUNC GLOBAL DEFAULT UND EVP_MD_CTX_copy_ex@OPENSSL_1_1_0 (6)
127: 00000000 0 FUNC GLOBAL DEFAULT UND EVP_MD_CTX_free@OPENSSL_1_1_0 (6)
129: 00000000 0 FUNC GLOBAL DEFAULT UND EVP_MD_CTX_new@OPENSSL_1_1_0 (6)
140: 00000000 0 FUNC GLOBAL DEFAULT UND EVP_MD_CTX_set_flags@OPENSSL_1_1_0 (6)
168: 00000000 0 FUNC GLOBAL DEFAULT UND EVP_MD_CTX_ctrl@OPENSSL_1_1_0 (6)
2413: 00000000 0 FUNC GLOBAL DEFAULT UND EVP_MD_CTX_md
2422: 00000000 0 FUNC GLOBAL DEFAULT UND EVP_MD_CTX_copy
2423: 00000000 0 FUNC GLOBAL DEFAULT UND EVP_MD_CTX_copy_ex
2425: 00000000 0 FUNC GLOBAL DEFAULT UND EVP_MD_CTX_free
2427: 00000000 0 FUNC GLOBAL DEFAULT UND EVP_MD_CTX_new
2438: 00000000 0 FUNC GLOBAL DEFAULT UND EVP_MD_CTX_set_flags
2466: 00000000 0 FUNC GLOBAL DEFAULT UND EVP_MD_CTX_ctrl
When I try to load the libraries on android with the following code,
System.loadLibrary("crypto");
System.loadLibrary("ssl");
System.loadLibrary("curl");
I get the following error:
E/art: dlopen("/data/app/com.example.lhahn.loadlibtest-1/lib/arm/libcurl.so", RTLD_LAZY) failed: dlopen failed: cannot locate symbol "EVP_MD_CTX_new" referenced by "libcurl.so"...
D/AndroidRuntime: Shutting down VM
E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.example.lhahn.loadlibtest, PID: 3925
java.lang.UnsatisfiedLinkError: dlopen failed: cannot locate symbol "EVP_MD_CTX_new" referenced by "libcurl.so"...
at java.lang.Runtime.loadLibrary(Runtime.java:371)
at java.lang.System.loadLibrary(System.java:989)
at com.example.lhahn.loadlibtest.MainActivity.onCreate(MainActivity.java:15)
at android.app.Activity.performCreate(Activity.java:6289)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1119)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2646)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2758)
at android.app.ActivityThread.access$900(ActivityThread.java:177)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1448)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:145)
at android.app.ActivityThread.main(ActivityThread.java:5942)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1400)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1195)
I/Process: Sending signal. PID: 3925 SIG: 9
Application terminated.
However, as you can see from the output of the commands, the symbol EVP_MD_CTX_new
is defined correctly (it seems so at least). The question now becomes, do you have any idea of what the problem might be? One thing that I do not understand is the symbol EVP_MD_CTX_new@OPENSSL_1_1_0 (3)
. I have no ideia what the suffix @OPENSSL_1_1_0 (3)
means.
Some things to note is that when compiling the OpenSSL lib statically with libcurl.so
the loadLibrary
call works correctly. Another thing is that I am compiling the OpenSSL library with the following call to make:
make SHLIB_VERSION_NUMBER= SHLIB_EXT=.so install
This is necessary in order for libcrypto.so
and libssl.so
to not receive a suffix version number. Maybe this could be an issue?