android jni openssl,c++ - Android NDK linking OpenSSL - Stack Overflow

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 toSSL_load_error_strings'

Error:(40) undefined reference to OPENSSL_add_all_algorithms_noconf'

Error:(42) undefined reference toCRYPTO_num_locks'

Error:(45) undefined reference to CRYPTO_set_locking_callback'

Error:(46) undefined reference toCRYPTO_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)

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值