I have built OpenSSL for Android(using ndk-build) and have linked it to my program. Compilation and linking works, but I get a run time error of UnsatisfiedLinkError.
More specifically, the program breaks on this code:
public class TestActivity extends Activity
{ // load the library - name matches jni/Android.mk
static {
System.loadLibrary("crypto2");
System.loadLibrary("ssl2"); // <=BREAKS HERE!
System.loadLibrary("Test");
}
It specifically breaks when loading ssl2, so it seems it was able to load crypto2.
I think I need to tell ssl2 that it use cryto2, I tried to do that on the Android.mk file, but it didn’t help.
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_MODULE := libcrypto2
LOCAL_SRC_FILES := OpenSSL/libcrypto2.so
include $(PREBUILT_SHARED_LIBRARY)
include $(CLEAR_VARS)
LOCAL_MODULE := libssl2
LOCAL_SRC_FILES := OpenSSL/libssl2.so
LOCAL_SHARED_LIBRARIES := libcrypto2
include $(PREBUILT_SHARED_LIBRARY)
include $(CLEAR_VARS) # Here we give our module name and source file(s)
LOCAL_C_INCLUDES := D:/DevelopTools/OpenSSL-WIN32/include $(LOCAL_PATH)/../../../Framework/Applications/FW2Prototype $(LOCAL_PATH)/../../../Graphics/Libraries/Common $(LOCAL_PATH)/../../../Input/Libraries/Common $(LOCAL_PATH)/../../../Audio/Libraries/Common $(LOCAL_PATH)/../../../Audio/Libraries/NullAudio $(LOCAL_PATH)/../../../Network/Libraries/Common
LOCAL_MODULE := Test
LOCAL_SRC_FILES := Test.cpp Reference.cpp JNINetwork.cpp JNIGraphics2D.cpp JNIInput.cpp JNIAudio.cpp Applications/FatalWars2/FatalWars2.cpp /../../../Audio/Libraries/NullAudio/NullAudio.cpp
LOCAL_SHARED_LIBRARIES := libcrypto2 libssl2
include $(BUILD_SHARED_LIBRARY)
Any idea what is wrong?
Thanks,
I “solved” this.
I simpley built openssl into a single so file. I built both crypto and ssl statically, so ssl’s dependency in crypto was hidden inside the static linking.
The issue is apparently that I couldn’t load the prebuilt shared library ssl, because it was dependant of another prebuilt shared library(crypto). Maybe it’s possible to load such libraries somehow, but my solution was just to static link crypto into ssl and then into a shared library called openssl.