android openssl 库,用于iOS和Android的OpenSSL库

OpenSSL & cURL Library for iOS and Androidlibraryversionplatform supportarch supportpull commit

openssl1.1.0fiosarmv7s armv7 i386 x86_64 arm64aae1672

androidarmeabi armeabi-v7a arm64-v8a x86 x86_64 mips mips64aae1672

curl7.53.1iosarmv7s armv7 i386 x86_64 arm64aae1672

androidarmeabi armeabi-v7a arm64-v8a x86 x86_64 mips mips64aae1672

English

Downloads

If you do not want to build it by yourself, you could download our prebuilt library from there

Android prebuilt library download from here!!!

OpenSSL Version

This a static library compile from openssl and cURL for iOS and Android.

cURL Version

Android NDK Versionandroid-ndk-r15 ( do not try to build use 15 it will fail )

how to build

for iOS

Copy openssl-1.1.0f.tar.gz to tools file folder and runcd tools

sh./build-openssl4ios.sh

Copy curl-7.53.1.tar.gz to tools file folder and runcd tools

sh./build-curl4ios.sh

for Android

Set ENV NDK_ROOTcd tools

sh./build-openssl4android.sh

You could build it with ABI likecd tools

sh./build-openssl4android.sh android # for armeabi

sh./build-openssl4android.sh android-armeabi #for armeabi-v7a

sh./build-openssl4android.sh android64-arm64 #for arm64_v8a

sh./build-openssl4android.sh android-x86 #for x86

sh./build-openssl4android.sh android64 #for x86_64

sh./build-openssl4android.sh mips #for mips

sh./build-openssl4android.sh mips64 #for mips64

you must build openssl first

else cURL HTTPS is disable (without ssl)

OpenSSL for Android is build with libz support using dynamic link.libz is publically provided by Android system.sh./build-curl4android.sh

You could build it with ABI likecd tools

sh./build-curl4android.sh android # for armeabi

sh./build-curl4android.sh android-armv7 #for armeabi-v7a

sh./build-curl4android.sh android64-arm64 #for arm64_v8a

sh./build-curl4android.sh android-x86 #for x86

sh./build-curl4android.sh android-x86_64 #for x86_64

sh./build-curl4android.sh mips #for mips

sh./build-curl4android.sh mips64 #for mips64

how to use

for iOS

Copy lib/libcrypto.a and lib/libssl.a and lib/libcurl.a to your project.

Copy include/openssl folder and include/curl folder to your project.

Add libcrypto.a and libssl.a and libcurl.a to Frameworks group and add them to[Build Phases] ====> [Link Binary With Libraries]

Add openssl include path and curl include path to your[Build Settings] ====> [User Header Search Paths]

about"__curl_rule_01__ declared as an array with a negative size"problem

When you build cURL for arm64 you will get this error.

You need to change curlbuild.h from :#defineCURL_SIZEOF_LONG4

to :#ifdef __LP64__

#defineCURL_SIZEOF_LONG8#else#defineCURL_SIZEOF_LONG4#endif

for Android

Copy lib/armeabi folder and lib/armeabi-v7a folder and lib/x86 to your android project libs folder.

Copy include/openssl folder and include/curl to your android project.Android Makefile

Add openssl include path to jni/Android.mk.#Android.mk

include $(CLEAR_VARS)

LOCAL_MODULE := curl

LOCAL_SRC_FILES := Your cURL Library Path/$(TARGET_ARCH_ABI)/libcurl.a

include $(PREBUILT_STATIC_LIBRARY)

LOCAL_C_INCLUDES :=

$(LOCAL_PATH)/Your Openssl Include Path/openssl

$(LOCAL_PATH)/Your cURL Include Path/curl

LOCAL_STATIC_LIBRARIES := libcurl

LOCAL_LDLIBS := -lz

CMake

Define ssl, crypto, curl as STATIC IMPORTED libraries.add_library(crypto STATIC IMPORTED)

set_target_properties(crypto

PROPERTIES IMPORTED_LOCATION ${CMAKE_SOURCE_DIR}/libs/${ANDROID_ABI}/libcrypto.a)

add_library(ssl STATIC IMPORTED)

set_target_properties(ssl

PROPERTIES IMPORTED_LOCATION ${CMAKE_SOURCE_DIR}/libs/${ANDROID_ABI}/libssl.a)

add_library(curl STATIC IMPORTED)

set_target_properties(curl

PROPERTIES IMPORTED_LOCATION ${CMAKE_SOURCE_DIR}/libs/${ANDROID_ABI}/libcurl.a)

Then link these libraries with your target, e.g.target_link_libraries( # Specifies the target library.

native-lib

curl

ssl

crypto

)

about"libcrypto.a(ui_openssl.o):ui_openssl.c:function read_string_inner :error : undefined reference to 'signal'"problem

when you get these errorlibcrypto.a(ui_openssl.o):ui_openssl.c:function read_string_inner: error: undefined reference to 'signal'

libcrypto.a(ui_openssl.o):ui_openssl.c:function read_string_inner: error: undefined reference to 'tcsetattr'

You need to rebuild OpenSSL static library with NDK API level 16 or earlier

If you build OpenSSL with API level 16 or earlier you may not build it for arch 64 bit only support 32 bit

more information :

Our build script default use API 16 to build OpenSSL

如果你不想自己构建,那么你可以使用我们已经预先构建好的版本, 请在这里下载

Android 编译好的库 从这里下载!!!

[Build Phases] ====> [Link Binary With Libraries]

[Build Settings] ====> [User Header Search Paths]

当你在 iOS 的 arm64 架构环境下编译 cURL 静态库时会遇到这个问题。解决的办法是修改 curlbuild.h 头文件,将下面这行 :#defineCURL_SIZEOF_LONG4

改成 :#ifdef __LP64__

#defineCURL_SIZEOF_LONG8#else#defineCURL_SIZEOF_LONG4#endif

# Android.mk

include $(CLEAR_VARS)

LOCAL_MODULE := curl

LOCAL_SRC_FILES := Your cURL Library Path/$(TARGET_ARCH_ABI)/libcurl.a

include $(PREBUILT_STATIC_LIBRARY)

include $(CLEAR_VARS)

LOCAL_MODULE := curl

LOCAL_SRC_FILES := Your cURL Library Path/$(TARGET_ARCH_ABI)/libcurl.a

include $(PREBUILT_STATIC_LIBRARY)

LOCAL_C_INCLUDES :=

$(LOCAL_PATH)/Your Openssl Include Path/openssl

$(LOCAL_PATH)/Your cURL Include Path/curl

LOCAL_STATIC_LIBRARIES := libcurl

LOCAL_LDLIBS := -lz

add_library(crypto STATIC IMPORTED)

set_target_properties(crypto

PROPERTIES IMPORTED_LOCATION ${CMAKE_SOURCE_DIR}/libs/${ANDROID_ABI}/libcrypto.a)

add_library(ssl STATIC IMPORTED)

set_target_properties(ssl

PROPERTIES IMPORTED_LOCATION ${CMAKE_SOURCE_DIR}/libs/${ANDROID_ABI}/libssl.a)

add_library(curl STATIC IMPORTED)

set_target_properties(curl

PROPERTIES IMPORTED_LOCATION ${CMAKE_SOURCE_DIR}/libs/${ANDROID_ABI}/libcurl.a)

target_link_libraries( # Specifies the target library.

native-lib

curl

ssl

crypto

)

关于"libcrypto.a(ui_openssl.o):ui_openssl.c:function read_string_inner :

libcrypto.a(ui_openssl.o):ui_openssl.c:function read_string_inner: error: undefined reference to 'signal'

libcrypto.a(ui_openssl.o):ui_openssl.c:function read_string_inner: error: undefined reference to 'tcsetattr'

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值