适用于 iOS 和 Android 的 OpenSSL 库
simple-build-ios-and-android-script
libraryversionplatform supportarch supportpull commit
openssl1.1.1diosarmv7 arm64 arm64e x86_64 aae1672
1.1.1tandroidarmeabi-v7a arm64-v8a x86 x86_64 aae1672
nghttp21.40.0iosarmv7 arm64 arm64e x86x86_64 aae1672
androidarmeabi-v7a arm64-v8a x86 x86_64 aae1672
curl7.68.0iosarmv7 arm64 arm64e x86_64 aae1672
androidarmeabi-v7a arm64-v8a x86 x86_64 aae1672
If you do not want to build it by yourself, you could download our prebuilt library from there
$ cd tools
$ sh build-ios-openssl.sh
$ sh build-ios-nghttp2.sh
$ sh build-ios-curl.shexport ANDROID_NDK_ROOT=/Location/where/installed/android-ndk-r21d
$ cd tools
$ export api=16
$ ./build-android-openssl.sh arm
$ ./build-android-nghttp2.sh arm
$ ./build-android-curl.sh arm
$ export api=21
$ ./build-android-openssl.sh arm64
$ ./build-android-nghttp2.sh arm64
$ ./build-android-curl.sh arm64You must build openssl and nghttp2(support http2) first
OpenSSL for Android is build with libz support using dynamic
link. libz is publically provided by Android system.
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]
When you build cURL for arm64 you will get this error.
You need to change curlbuild.h from :
#define CURL_SIZEOF_LONG 4to :
#ifdef __LP64__
#define CURL_SIZEOF_LONG 8
#else
#define CURL_SIZEOF_LONG 4
#endifCopy 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.
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
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
)when you get these error
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' 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 :
暂无开放 Issues,或尚未同步最近议题。