To use Libcurl on Android and to support the HTTPS protocol, you need to rely on OpenSSL, so first look at how to compile OpenSSL
1. Compiling shared libraries under arm (default)
I am using Guardianproject's OpenSSL, which has already provided the Android NDK makefile.
git clone https://github.com/guardianproject/openssl-android.git
Then directly CD to the directory, $NDK/ndk-build on the line.
Note The default is to use ndkr5b, and if this version is not available, modify the Toolchain version in Jni/application.mk
This compiles the shared libraries (libcrypto.so and libssl.so) under arm, which can already be used with Libcurl to support HTTPS.
2. Compiling a static library under arm
Modify the CRYPTO/ANDROID.MK First:
# target
Include $ (clear_vars)
Include $ (local_path)/. /android-config.mk
Local_src_files + = $ (local_src_files)
Local_cflags + = $ (local_c_flags)
Local_c_includes + = $ (local_c_includes)
Local_ldlibs + =-lz
Ifeq ($ (target_arch), arm)
Local_src_files + = $ (arm_src_files)
Local_cflags + = $ (arm_cflags)
Else
Local_src_files + = $ (non_arm_src_files)
endif
Ifeq ($ (target_simulator), true)
# Make Valgrind happy.
Local_cflags + =-dpurify
Local_ldlibs + =-ldl
endif
Local_module_tags: = Optional
local_module:= Libcrypto
Include $ (build_static_library)
is to change the last build_shared_library to Build_static_library, and the other module in the back.
Then modify the SSL/ANDROID.MK:
Include $ (clear_vars)
Include $ (local_path)/. /android-config.mk
Local_src_files + = $ (local_src_files)
Local_c_includes + = $ (local_c_includes)
Local_static_libraries + = Libcrypto
Local_module_tags: = Optional
local_module:= Libssl
Include $ (build_static_library)
is to have the shared cache static, and the rest of the module will be erased.
3. Compiling the X86 version of the static library
Modify JNI/APPLICATION.MK:
ndk_toolchain_version=4.6
App_project_path: = $ (shell pwd)
App_abi: = x86
Target_arch: = x86
App_build_script: = $ (App_project_path)/android.mk
is to add the ABI and arch restrictions, and then the tool even version, because the default ndkr5b does not seem to support x86, so change a higher version of the NDK
Http://www.cnblogs.com/guoxiaoqian/p/4199576.html
UBUNTU+NDK compiling OpenSSL (for Android with Libcurl and HTTPS protocol support)