UBUNTU+NDK compiling OpenSSL (for Android with Libcurl and HTTPS protocol support)

Source: Internet
Author: User

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)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.