Add Curl solutions to Android _android

Source: Internet
Author: User
Tags curl openssl file transfer protocol

Curl is a well-known open source file Transfer Protocol implementation software, including HTTP, HTTPS, FTP and other commonly used not common protocol implementation. The latest version of Curl's official source code already includes the Android compilation file (ANDROID.MK), but there is still work to do to compile it.

The Curl version I use is the 7.20.0,android source version is Eclair 2.1.
First of all, curl uncompressed to the external directory, the directory name changed to curl (can not change, but the habit of Android is not with version number, as in the Romans).

(1) First to create a header file curl_config.h. the creation method is described in a comment in the header of the curl/ file. Run Configure according to this description. I use the following command line (I was compiled into x86 version, but our goal is to generate curl_config.h files, so x86 or arm is actually the same):

Copy Code code as follows:

Android_root= ' Realpath. /.. ' && path= ' $ANDROID _root/prebuilt/linux-x86/toolchain/i686-unknown-linux-gnu-4.2.1/bin: $PATH./configure --host=x86-linux CC=I686-UNKNOWN-LINUX-GNU-GCC cppflags= "-I $ANDROID _root/external/curl/include/ -i $ANDROID _ Root/external/curl -i $ANDROID _root/out/target/product/eeepc/obj/static_libraries/libcurl_intermediates  -i $ANDROID _root/system/core/include -i $ANDROID _root/hardware/libhardware/include -i $ANDROID _ Root/hardware/libhardware_legacy/include -i $ANDROID _root/hardware/ril/include -i $ANDROID _root/dalvik /libnativehelper/include -i $ANDROID _root/frameworks/base/include -i $ANDROID _root/frameworks/base/ Opengl/include -i $ANDROID _root/external/skia/include -i $ANDROID _root/out/target/product/eeepc/obj/ Include -i $ANDROID _root/bionic/libc/arch-x86/include -i $ANDROID _root/bionic/libc/include -i $ Android_root/bionic/libstdc++/include -i $ANDROID _root/bionic/libc/kernel/commoN -i $ANDROID _root/bionic/libc/kernel/arch-x86 -i $ANDROID _root/bionic/libm/include -i $ANDROID _ Root/bionic/libm/include/i387 -i $ANDROID _root/bionic/libthread_db/include-i $ANDROID _root/external/openssl /include "cflags="-fno-exceptions-wno-multichar-march=i686-m32-fpic-include $ANDROID _root/system/core/include/ Arch/target_linux-x86/androidconfig.h-m32-dandroid-fmessage-length=0-fno-strict-aliasing-wno-unused-winit-self -wpointer-arith-werror=return-type-werror=non-virtual-dtor-werror=address-werror=sequence-point-wpointer-arith -wwrite-strings-wunused-winline-wnested-externs-wmissing-declarations-wmissing-prototypes-wno-long-long- Wfloat-equal-wno-multichar-wsign-compare-wno-format-nonliteral-wendif-labels-wstrict-prototypes- Wdeclaration-after-statement-wno-system-headers "lib=" $ANDROID _root/prebuilt/linux-x86/toolchain/ I686-UNKNOWN-LINUX-GNU-4.2.1/LIB/GCC/I686-UNKNOWN-LINUX-GNU/4.2.1/LIBGCC.A $ANDROID _root/prebuilt/linux-x86/ Toolchain/I686-UNKNOWN-LINUX-GNU-4.2.1/LIB/GCC/I686-UNKNOWN-LINUX-GNU/4.2.1/CRTBEGIN.O $ANDROID _root/prebuilt/linux-x86/ TOOLCHAIN/I686-UNKNOWN-LINUX-GNU-4.2.1/LIB/GCC/I686-UNKNOWN-LINUX-GNU/4.2.1/CRTEND.O "

(2) Configure cannot find the OpenSSL, so the generated configuration file is not using OpenSSL. To use SSL, you need to manually modify lib/curl_config.h and src/curl_config.h to open the macro definition Have_libssl, Have_openssl_crypto_h, Have_openssl_err_h, Have_openssl_pem_h, Have_openssl_pkcs12_h, Have_openssl_rsa_h, Have_openssl_ssl_h, HAVE_OPENSSL_X509_H, USE_OPENSSL , Use_ssleay (but note that Android does not compile the engine in OPENSSL, so do not open the macro definition Have_openssl_engine_h), and comment out the macro definition Have_malloc_h and Have_ioctl, These two macro definitions are defined in the android_config.h and there will be many warnings during compilation (but they can be compiled correctly).

(3) Modify the Curl/ file, add External/openssl/include in the value of the local_c_includes variable, and increase the value of the local_system_shared_libraries variable Libssl libz Libcrypto.

Okay, now you can compile:
Make Curl One_shot_makefile=external/curl/ target_product=<...>

However, the above file will libcurl compiled into a static library, to be compiled into a dynamic library also need to modify the file.

Related Article

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: 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.