1. Port the Curl tool to the Android 2.3 environment step 1. Download the curl Source Code directly to the website. 2. Use tar in the android compiling environment, usually put in the external directory 3. Because Curl depends on some header files and definitions, You need to first execute the configuration file and compile curl under external/curl. sh requires cd external/curl /. curl. sh, or put it in the android root directory *. sh Script: source external/curl. sh: The CURL path, compilation tool chain path, and other variables [cpp] #! /Bin/bash ANDROID_HOME_CURL = .. /.. /& \ NDK_HOME_CURL = .. /.. /ndk & \ PATH = "$ ANDROID_HOME_CURL/prebuilt/linux-x86/toolchain/arm-eabi-4.4.0/bin: $ PATH "\. /configure -- host = arm-linux CC = arm-eabi-gcc -- with-random =/dev/urandom \ CPPFLAGS = "-I $ NDK_HOME_CURL/platforms/android-8/arch -arm/usr/include \-I $ ANDROID_HOME_CURL/external/curl/include/\-I $ ANDROID_HOME_CURL/external/curl/3rd/include \-I $ ANDRO ID_HOME_CURL/external/curl \-I $ response/out/target/product/generic/obj/STATIC_LIBRARIES/libcurl_intermediates \-I $ response/dalvik/libnativehelper/include/nativehelper \-I $ users/system/core/include \-I $ ANDROID_HOME_CURL/hardware/libhardware/include \-I $ users/hardware/libhardware_legacy/include \-I $ ANDROID_HOME_CURL/hardware/ril/ include \-I $ AND Examples/dalvik/libnativehelper/include \-I $ ANDROID_HOME_CURL/frameworks/base/opengl/include \-I $ ANDROID_HOME_CURL/frameworks/base /native/include \-I $ ANDROID_HOME_CURL/external/skia/include \-I $ ANDROID_HOME_CURL/out/target/product/generic/obj/include \-I $ ANDROID_HOME_CURL/bionic/ libc/arch-arm/include \-I $ ANDROID_HOME_CURL/bionic/lib C/include \-I $ ANDROID_HOME_CURL/bionic/libstdc ++/include \-I $ ANDROID_HOME_CURL/bionic/libc/kernel/common \-I $ ANDROID_HOME_CURL/bionic/libc/kernel /arch-arm \-I $ ANDROID_HOME_CURL/bionic/libm/include/arch/arm \-I $ ANDROID_HOME_CURL/bionic/libthread_db/ include \-include $ ANDROID_HOME_CURL/system/core/include/arch/linux-arm/AndroidConfig. h \-I $ AND ROID_HOME_CURL/system/core/include/arch/linux-arm/\-d1_arm_arch_5 _-KERNEL _-d1_arm_arch_5te _-DANDROID-DNDEBUG-DHAVE_CONFIG_H" \ CFLAGS = "-fno-tions-Wno-multichar-msoft-float-fpic-ffunction-sections \-funwind-tables-fstack-protector-Wa, -- noexecstack-Werror = format-security \-fno-short-enums-march = armv5te-mtune = xscale-Wno-psabi-mthumb-inter Work \-fmessage-length = 0-W-Wall-Wno-unused-Winit-self-Wpointer-arith \-Werror = return-type-Werror = non-virtual-dtor- werror = address-Werror = sequence-point \-g-Wstrict-aliasing = 2-finline-functions-fno-inline-functions-called-once \-fgcse-after-reload- frerun-cse-after-loop-frename-registers-UDEBUG \-mthumb-OS-fomit-frame-pointer-fno-strict-aliasing-finline-limit = 64 \-Wpointer- ari Th-Wwrite-strings-Wunused-Winline-Wnested-externs \-Wmissing-declarations-Wmissing-prototypes-Wno-long-Wfloat-equal \-Wno-multichar-Wsign- compare-Wno-format-nonliteral-Wendif-labels \-Wstrict-prototypes-Wdeclaration-after-statement-Wno-system-headers "\ LIBS ="-nostdlib-Bdynamic-Wl, -T, $ ANDROID_HOME_CURL/build/core/armelf. x \-Wl,-dynamic-linker,/system/bin/linker-Wl, -- gc-sect Ions-Wl,-z, nocopyreloc \-L $ ANDROID_HOME_CURL/out/target/product/generic/obj/lib-Wl,-z, noexecstack \-Wl, -rpath-link = $ ANDROID_HOME_CURL/out/target/product/generic/obj/lib \-lc-llog-lcutils-lstdc ++ \-Wl, -- no-undefined $ ANDROID_HOME_CURL/prebuilt/linux-x86/toolchain/arm-eabi-4.4.0/lib/gcc/arm-eabi/4.4.0/libgcc. a \ $ ANDROID_HOME_CURL/out/target/product/generic/obj/lib/crtend_android.o \-lm $ NDROID_HOME_CURL/out/target/product/generic/obj/lib/crtbegin_dynamic.o \-L $ ANDROID_HOME_CURL/external/curl/3rd/libs "#! /Bin/bash ANDROID_HOME_CURL = .. /.. /& \ NDK_HOME_CURL = .. /.. /ndk & \ PATH = "$ ANDROID_HOME_CURL/prebuilt/linux-x86/toolchain/arm-eabi-4.4.0/bin: $ PATH "\. /configure -- host = arm-linux CC = arm-eabi-gcc -- with-random =/dev/urandom \ CPPFLAGS = "-I $ NDK_HOME_CURL/platforms/android-8/arch -arm/usr/include \-I $ ANDROID_HOME_CURL/external/curl/include/\-I $ ANDROID_HOME_CURL/external/curl/3rd/include \-I $ ANDROID_HOME _ CURL/external/curl \-I $ response/out/target/product/generic/obj/STATIC_LIBRARIES/libcurl_intermediates \-I $ response/dalvik/libnativehelper/include/nativehelper \- I $ users/system/core/include \-I $ ANDROID_HOME_CURL/hardware/libhardware/include \-I $ ANDROID_HOME_CURL/hardware/libhardware_legacy/include \-I $ users/hardware/ril /include \-I $ ANDROID_HOME_CURL /Dalvik/libnativehelper/include \-I $ ANDROID_HOME_CURL/frameworks/base/opengl/include \-I $ ANDROID_HOME_CURL/frameworks/base/ native/include \-I $ ANDROID_HOME_CURL/external/skia/include \-I $ ANDROID_HOME_CURL/out/target/product/generic/obj/include \-I $ ANDROID_HOME_CURL/bionic/libc /arch-arm/include \-I $ ANDROID_HOME_CURL/bionic/libc/include \-I $ ANDROI D_HOME_CURL/bionic/libstdc ++/include \-I $ ANDROID_HOME_CURL/bionic/libc/kernel/common \-I $ ANDROID_HOME_CURL/bionic/libc/kernel/arch-arm \-I $ category/bionic/libm/include \-I $ ANDROID_HOME_CURL/bionic/libm/include/arch/arm \-I $ ANDROID_HOME_CURL/bionic/libthread_db/include \-include $ ANDROID_HOME_CURL/ system/core/include/arch/linux-arm/AndroidConfig. h \-I $ ANDROID_HOME_CURL/system/core/in Clude/arch/linux-arm/\-d1_arm_arch_5 _-KERNEL _-d1_arm_arch_5te _-DANDROID-DNDEBUG-DHAVE_CONFIG_H "\ CFLAGS ="-fno -exceptions-Wno-multichar-msoft-float-fpic-ffunction-sections \-funwind-tables-fstack-protector-Wa, -- noexecstack-Werror = format-security \-fno-short-enums-march = armv5te-mtune = xscale-Wno-psabi-mthumb-interwork \-fmessage-length = 0-W -Wall -Wno-unused-Winit-self-Wpointer-arith \-Werror = return-type-Werror = non-virtual-dtor-Werror = address-Werror = sequence-point \-g -Wstrict-aliasing = 2-finline-functions-fno-inline-functions-called-once \-fgcse-after-reload-frerun-cse-after-loop-frename-registers- UDEBUG \-mthumb-OS-fomit-frame-pointer-fno-strict-aliasing-finline-limit = 64 \-Wpointer-arith-Wwrite-strings-Wunused-Winline-W Nested-externs \-Wmissing-declarations-Wmissing-prototypes-Wno-long-Wfloat-equal \-Wno-multichar-Wsign-compare-Wno-format-nonliteral-Wendif- labels \-Wstrict-prototypes-Wdeclaration-after-statement-Wno-system-headers "\ LIBS ="-nostdlib-Bdynamic-Wl, -T, $ ANDROID_HOME_CURL/build/core/armelf. x \-Wl,-dynamic-linker,/system/bin/linker-Wl, -- gc-sections-Wl,-z, nocopyreloc \-L $ ANDROID_HOME_CUR L/out/target/product/generic/obj/lib-Wl,-z, noexecstack \-Wl, -rpath-link = $ ANDROID_HOME_CURL/out/target/product/generic/obj/lib \-lc-llog-lcutils-lstdc ++ \-Wl, -- no-undefined $ ANDROID_HOME_CURL/prebuilt/linux-x86/toolchain/arm-eabi-4.4.0/lib/gcc/arm-eabi/4.4.0/libgcc. a \ $ ANDROID_HOME_CURL/out/target/product/generic/obj/lib/crtend_android.o \-lm $ ANDROID_HOME_CURL/out/target/product/generic/obj/li B/crtbegin_dynamic.o \-L $ ANDROID_HOME_CURL/external/curl/3rd/libs "4. Compile the android. mk compilation script and add compilation to generate libcurl. so dynamic library [cpp] view plaincopyprint? LOCAL_PATH: = $ (call my-dir) common_CFLAGS: =-Wpointer-arith-Wwrite-strings-Wunused-Winline-Wnested-externs-Wmissing-declarations-Wmissing-prototypes-Wno-long-Wfloat-equal-Wno-multichar- wsign-compare-Wno-format-nonliteral-Wendif-labels-Wstrict-prototypes-Wdeclaration-after-statement-Wno-system-headers-DHAVE_CONFIG_H ######### ################ Build the libcurl library include $ (CLEAR_VARS) include $ (LOCAL_PATH)/lib/Makefile. inc CURL_HEADERS: = \ curlbuild. h \ curl. h \ curlrules. h \ curlver. h \ easy. h \ mprintf. h \ multi. h \ stdcheaders. h \ typecheck-gcc.h LOCAL_SRC_FILES: = $ (addprefix lib/, $ (CSOURCES) LOCAL_C_INCLUDES + = $ (LOCAL_PATH)/include/LOCAL_CFLAGS + = $ (common_CFLAGS) LOCAL_COPY_HEADERS_TO: = libcurl/curl LOCAL_COPY_HEADERS: = $ (addprefix include/curl/, $ (CURL _ HEADERS) LOCAL_PRELINK_MODULE: = false LOCAL_MODULE: = libcurl LOCAL_MODULE_TAGS: = optional # Copy the licence to a place where Android will find it. # Actually, this doesn' t quite work because the build system searches # for NOTICE files before it gets to this point, so it will only be seen # on subsequent builds. ALL_PREBUILT + = $ (LOCAL_PATH)/NOTICE: $ (LOCAL_PATH)/COPYING | $ (ACP) $ (copy-file-to-target) include $ (BUILD_STATIC_LIBRARY) include $ (CLEAR_VARS) include $ (LOCAL_PATH)/lib/Makefile. inc CURL_HEADERS: = \ curlbuild. h \ curl. h \ curlrules. h \ curlver. h \ easy. h \ mprintf. h \ multi. h \ stdcheaders. h \ typecheck-gcc.h LOCAL_SRC_FILES: = $ (addprefix lib/, $ (CSOURCES) LOCAL_C_INCLUDES + = $ (LOCAL_PATH)/include/LOCAL_CFLAGS + = $ (common_CFLAGS) LOCAL_COPY_HEADERS_T O: = libcurl/curl LOCAL_COPY_HEADERS :=$ (addprefix include/curl/, $ (CURL_HEADERS) LOCAL_PRELINK_MODULE: = false LOCAL_MODULE: = libcurl LOCAL_MODULE_TAGS: = optional # Copy the licence to a place where Android will find it. # Actually, this doesn' t quite work because the build system searches # for NOTICE files before it gets to this point, so it will only be seen # on subsequent builds. ALL_PREBU ILT + = $ (LOCAL_PATH)/NOTICE: $ (LOCAL_PATH)/COPYING | $ (ACP) $ (copy-file-to-target) include $ (BUILD_SHARED_LIBRARY) ########################## Build the curl binary include $ (CLEAR_VARS) include $ (LOCAL_PATH)/src/Makefile. inc LOCAL_SRC_FILES: = $ (addprefix src/, $ (CURL_CFILES) LOCAL_MODULE: = curl LOCAL_MODULE_TAGS: = optional LOCAL_SHARED_LIBRARIES: = libcurl LOCAL_SYSTEM_SHA RED_LIBRARIES: = libc LOCAL_C_INCLUDES + = $ (LOCAL_PATH)/include $ (LOCAL_PATH)/lib # This may also need to include $ (CURLX_ONES) in order to correctly link # if libcurl is changed to be built as a dynamic library LOCAL_CFLAGS + =$ (common_CFLAGS) include $ (BUILD_EXECUTABLE) LOCAL_PATH :=$ (call my-dir) common_CFLAGS: =-Wpointer-arith-Wwrite-strings-Wunused-Winline-Wnested-externs-Wmissing-decia Rations-Wmissing-prototypes-Wno-long-Wfloat-equal-Wno-multichar-Wsign-compare-Wno-format-nonliteral-Wendif-labels-Wstrict-prototypes-Wdeclaration- after-statement-Wno-system-headers-DHAVE_CONFIG_H ######################## Build the libcurl library include $ (CLEAR_VARS) include $ (LOCAL_PATH)/lib/Makefile. incCURL_HEADERS: = \ curlbuild. h \ curl. h \ curlrules. h \ curlver. h \ easy. h \ mprint F. h \ multi. h \ stdcheaders. h \ typecheck-gcc.h LOCAL_SRC_FILES: = $ (addprefix lib/, $ (CSOURCES) LOCAL_C_INCLUDES + = $ (LOCAL_PATH)/include/LOCAL_CFLAGS + = $ (common_CFLAGS) LOCAL_COPY_HEADERS_TO: = libcurl/curlLOCAL_COPY_HEADERS: = $ (addprefix include/curl/, $ (CURL_HEADERS) LOCAL_PRELINK_MODULE: = falseLOCAL_MODULE: = Authorization: = optional # Copy the licence to a place where Android will f Ind it. # Actually, this doesn' t quite work because the build system searches # for NOTICE files before it gets to this point, so it will only be seen # on subsequent builds. ALL_PREBUILT + = $ (LOCAL_PATH)/NOTICE: $ (LOCAL_PATH)/COPYING | $ (ACP) $ (copy-file-to-target) include $ (BUILD_STATIC_LIBRARY) include $ (CLEAR_VARS) include $ (LOCAL_PATH)/lib/Makefile. incCURL_HEADERS: = \ curlbuild. H \ curl. h \ curlrules. h \ curlver. h \ easy. h \ mprintf. h \ multi. h \ stdcheaders. h \ typecheck-gcc.h LOCAL_SRC_FILES: = $ (addprefix lib/, $ (CSOURCES) LOCAL_C_INCLUDES + = $ (LOCAL_PATH)/include/LOCAL_CFLAGS + = $ (common_CFLAGS) LOCAL_COPY_HEADERS_TO: = libcurl/curlLOCAL_COPY_HEADERS: = $ (addprefix include/curl/, $ (CURL_HEADERS) LOCAL_PRELINK_MODULE: = falseLOCAL_MODULE: = libcurlLOCAL_MODULE_TAGS: = optional # Copy the licence to a place where Android will find it. # Actually, this doesn' t quite work because the build system searches # for NOTICE files before it gets to this point, so it will only be seen # on subsequent builds. ALL_PREBUILT + = $ (LOCAL_PATH)/NOTICE: $ (LOCAL_PATH)/COPYING | $ (ACP) $ (copy-file-to-target) include $ (BUILD_SHARED_LIBRARY) ########################## Build Curl binary include $ (CLEAR_VARS) include $ (LOCAL_PATH)/src/Makefile. incLOCAL_SRC_FILES: = $ (addprefix src/, $ (CURL_CFILES) LOCAL_MODULE: = curlLOCAL_MODULE_TAGS: = runtime: = libc LOCAL_C_INCLUDES + = $ (LOCAL_PATH)/include $ (LOCAL_PATH) /lib # This may also need to include $ (CURLX_ONES) in order to correctly link # if libcurl is changed t O be built as a dynamic libraryLOCAL_CFLAGS + = $ (common_CFLAGS) include $ (BUILD_EXECUTABLE) The libcurl will be generated under/system/lib without any errors. so and curl executable files under/system/bin 2. Test the interface function # include "curl/curl. h "# include <stdio. h>; int main () {CURL * curl; CURLcode res; curl_global_init (CURL_GLOBAL_ALL); curl = curl_easy_init (); if (curl) {curl_easy_setopt (curl, CURLOPT_URL, "http://www.baidu.com/"); res = curl_eas Y_perform (curl); if (0! = Res) {printf ("curl error: % d \ n", res) ;}curl_easy_cleanup (curl) ;}curl_global_cleanup (); return 0 ;} compile a corresponding android. mk generates the executable file: LOCAL_PATH: = $ (call my-dir) include $ (CLEAR_VARS) LOCAL_C_INCLUDES + =\$ (TOP)/external/curl/include/\ LOCAL_SRC_FILES: = curl_test.cpp LOCAL_SHARED_LIBRARIES: = libcurl LOCAL_MODULE_TAGS: = optional LOCAL_MODULE: = curl_test include $ (BUILD_EXECUTABLE). The output content is Open the source code of the http://www.baidu.com/Page 3, compile the problem please according to the specific android version and path to modify the curl. sh file and re-execute it, temporarily did not encounter other problems.