需要NDK
需要cywin
curl已经有编译文件
curl/packages/Android/Android.mk
首先需要运行configure脚本,产生curl_config.h
正常./configure --host=arm-linux 应该可以产生出一个curl_config.h,但是这个是cywin相关的。(用的是cywin的头文件)
可以定义CC变量
NDK=/cygdrive/c/android-ndk-r9d
GCC_PATH=$NDK/toolchains/arm-linux-androideabi-4.8/prebuilt/windows/bin
CC="arm-linux-androideabi-gcc -nostdlib"
PATH="$NDK:$GCC_PATH:$PATH"
export NDK
export PATH
export CC
然后继续执行./configure --host=arm-linux --without_openssl --without_libssh2
checking for ANSI C header files... no
checking for sys/types.h... (cached) no
checking for sys/stat.h... no
checking for stdlib.h... no
checking for string.h... no
checking for memory.h... no
checking for strings.h... no
checking for inttypes.h... (cached) no
checking for stdint.h... (cached) no
checking for unistd.h... no
checking size of long... 0
checking size of void*... 0
configure: error: cannot find out size of long.
到这里还是走不通。其实configure仅仅是产生一个cur_config.h头文件。
稍微修改curl的Android.mk
LOCAL_PATH:= $(call my-dir)/../..
注释掉
#########################
# 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_STATIC_LIBRARIES := libcurl
#LOCAL_SYSTEM_SHARED_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)
然后使用ndk-build -C your_curl_dir/package/android
然后开始编译,如果发现错误,直接去修改curl_config.h.直到通过为止.(这一步应该不难)
curl_config.h片段
---------------------------------------
/* #define HAVE_LBER_H 1 */
/* Define to 1 if you have the ldap.h header file. */
/* #define HAVE_LDAP_H 1 */
另外在Android目录下再放入一个Application.mk
加入
APP_ABI:=all
将同时产生多个架构的.a文件
==================================================
多看看NDK下的docs