需要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

本文档详细介绍了如何在Android环境下编译curl库。首先,你需要NDK和cygwin。curl的Android.mk文件已经存在。通过运行configure脚本并自定义CC变量,如指定NDK路径和arm-linux-androideabi-gcc编译器。在配置过程中可能会遇到问题,但主要目标是生成curl_config.h。然后修改Android.mk,注释掉构建curl二进制的部分,并使用ndk-build进行编译。如果遇到错误,直接修改curl_config.h。最后,创建一个Application.mk文件以生成多架构的静态库。
4506

被折叠的 条评论
为什么被折叠?



