I want to use openssl to my android ndk project.
But when I build it, I got these errors:
Error:(38) undefined reference to
SSL_library_init' Error:(39) undefined reference to
SSL_load_error_strings' Error:(40) undefined reference toOPENSSL_add_all_algorithms_noconf' Error:(42) undefined reference to
CRYPTO_num_locks' Error:(45) undefined reference toCRYPTO_set_locking_callback' Error:(46) undefined reference to
CRYPTO_set_id_callback' etc..
I've included two files to Android.mk (one to ssl, one to crypto):
//libcrypto.mk
include $(CLEAR_VARS)
LOCAL_MODULE := ssl-crypto
LOCAL_SRC_FILES := ../libs/system/$(TARGET_ARCH_ABI)/libcrypto.so
include $(PREBUILT_SHARED_LIBRARY)
//libssl.mk
include $(CLEAR_VARS)
LOCAL_MODULE := ssl-ssl
LOCAL_SRC_FILES := ../libs/system/$(TARGET_ARCH_ABI)/libssl.so
include $(PREBUILT_SHARED_LIBRARY)
And I've added this to app/build.gradle:
stl = "gnustl_static"
cppFlags += "-I${file("../../../../support-lib/jni")}".toString()
cppFlags += "-I${file("../../../generated-src/cpp")}".toString()
cppFlags += "-I${file("../../../taps-api")}".toString()
cppFlags += "-I${file("../../../include")}".toString()
cppFlags += "-std=c++11"
cppFlags += "-DASIO_STANDALONE"
cppFlags += "-lssl"
cppFlags += "-lcrypto"
I'm using openssl from C++, and generate jni wrappers with dropbox/djinni. Also I'm using Android Studio 1.3 stable and gradle 2.5
EDIT: I changed my build.gradle in the app:
abiFilters += "armeabi"
abiFilters += "armeabi-v7a"
abiFilters += "x86"
abiFilters += "mips"
ldLibs += ['ssl', 'crypto']
android.sources {
main {
jniLibs {
source {
srcDirs 'jni/libs'
}
}
}
It worked, but the app crashed (because it's searching the libs in a wrong directory in the apk...). Also I found that in the new experimental gradle recently not supports this 'third-party shared lib including thing'. So I'll have to wait for it. (Also I can try something with the makefiles, but default they skipped by AS)