操作系统是Ubuntu 10.04(x64)
1。安装 Ubuntu 10.04, 可以到 mirrors.163.com 下载,注意不要安装更新
我试过在MAC OSX 和更高版本操作Android平台,不过总是出错,因此只能选择这个版本
2。安装 JAVA jdk6.并设置JAVA环境
必须到oracle网站手动下载(还需要注册,真讨厌)jdk-6u43-linux-x64.bin
$ sudo mkdir /usr/lib/jvm
$ sudo cp jdk-6u43-linux-x64.bin /usr/lib/jvm
$ cd /usr/lib/jvm
$ sudo chmod +x jdk-6u43-linux-x64.bin
$ sudo ./jdk-6u43-linux-x64.bin
编辑 /etc/environment,添加
PATH=”……:/usr/lib/jvm/jdk1.6.0_43/bin”
CLASSPATH=.:/ usr/lib/jvm/jdk1.6.0_43/lib
JAVA_HOME=/usr/lib/jvm/jdk1.6.0_43
执行 . /etc/environment 更新
3。更新其它操作系统插件
$ sudo add-apt-repository "deb http://archive.canonical.com/ lucid partner"
$ sudo apt-get update
$ sudo apt-get install sun-java6-jdk
$ sudo apt-get install git-core gnupg flex bison gperf build-essential \
zip curl zlib1g-dev libc6-dev lib32ncurses5-dev ia32-libs \
x11proto-core-dev libx11-dev lib32readline5-dev lib32z-dev \
libgl1-mesa-dev g++-multilib mingw32 tofrodos python-markdown \
libxml2-utils xsltproc
$ sudo ln -s /usr/lib32/mesa/libGL.so.1 /usr/lib32/mesa/libGL.so
4。需要更新 git
$ sudo apt-add-repository ppa:git-core/ppa
$ sudo apt-get update
$ sudo apt-get install git
5。设置环境变量更新代码
$ cd ~
$ mkdir bin
$ PATH=~/bin:$PATH
Download the Repo tool and ensure that it is executable:
$ curl https://dl-ssl.google.com/dl/googlesource/git-repo/repo > ~/bin/repo
$ chmod a+x ~/bin/repo
$ mkdir working
$ cd working
$ repo init -u https://android.googlesource.com/platform/manifest -b gingerbread-release
如果出错,按提示设置Email和用户名
$ repo sync
重复执行直至成功为止
6。编译 Android2.3 源代码
$ . build/envsetup.sh
$ lunch
$ make -j4
7。下载NDK并解压
8。下载 curl 并解压到 android 2.3 源代码 external 目录下,然后把目录改为 curl(Android惯例,不改也可以)
9。编译 CURL, 打开一个新的终端,执行
$ export NDK_ROOT=/YOUR/NDK/PATH
$ export CC="$NDK_ROOT/prebuilt/linux-x86_64/bin/arm-linux-androideabi-gcc --sysroot= NDK_ROOT/platforms/android-8/arch-arm"
$ cd external/curl
$./configure --host=arm-linux-androideabi --disable-debug --enable-optimize --disable-curldebug --disable-telnet --disable-dict --disable-tftp --disable-pop3 --disable-imap --disable-smtp --disable-gopher --disable-manual --disable-rtsp --without-zlib --enable-crypto-auth
这一步是为了生成config文件,不需要继续执行make,如果需要支持OpenSSL,打开 lib/curl_config.h,添加以下内容
#define HAVE_LIBSSL 1
#define HAVE_OPENSSL_CRYPTO_H 1
#define HAVE_OPENSSL_ERR_H 1
#define HAVE_OPENSSL_PEM_H 1
#define HAVE_OPENSSL_PKCS12_H 1
#define HAVE_OPENSSL_RSA_H 1
#define HAVE_OPENSSL_SSL_H 1
#define HAVE_OPENSSL_X509_H 1
#define USE_OPENSSL 1
#define USE_SSLEAY 1
设置source 编译环境,然后继续
$ cd ../..
$ . build/envsetup.h
$ lunch
$ cd external/curl/packet/Android
$ 修改Android.mk文件,在LOCAL_C_INCLUDES += $(LOCAL_PATH)/include/ 后添加
LOCAL_C_INCLUDES += $(LOCAL_PATH)/../openssl/include
把 include $(BUILD_STATIC_LIBRARY) 改为
LOCAL_SYSTEM_SHARED_LIBRARIES := libc libssl libcrypto
include $(BUILD_SHARED_LIBRARY)
$ mm
从 out 目录中找出 libcurl.so 使用
记得在JAVA代码中加上 System.loadLibrary(“curl”);
后记,折腾了好几天,走了无数弯路后,终于总结出了这些步骤,执行这些步骤后 libcurl.so 可以使用,但其SSL功能尚未调通,仍需继续努力
1。安装 Ubuntu 10.04, 可以到 mirrors.163.com 下载,注意不要安装更新
2。安装 JAVA jdk6.并设置JAVA环境
必须到oracle网站手动下载(还需要注册,真讨厌)jdk-6u43-linux-x64.bin
$ sudo mkdir /usr/lib/jvm
$ sudo cp jdk-6u43-linux-x64.bin /usr/lib/jvm
$ cd /usr/lib/jvm
$ sudo chmod +x jdk-6u43-linux-x64.bin
$ sudo ./jdk-6u43-linux-x64.bin
编辑 /etc/environment,添加
PATH=”……:/usr/lib/jvm/jdk1.6.0_43/bin”
CLASSPATH=.:/ usr/lib/jvm/jdk1.6.0_43/lib
JAVA_HOME=/usr/lib/jvm/jdk1.6.0_43
执行 . /etc/environment 更新
3。更新其它操作系统插件
$ sudo add-apt-repository "deb http://archive.canonical.com/ lucid partner"
$ sudo apt-get update
$ sudo apt-get install sun-java6-jdk
$ sudo apt-get install git-core gnupg flex bison gperf build-essential \
$ sudo ln -s /usr/lib32/mesa/libGL.so.1 /usr/lib32/mesa/libGL.so
4。需要更新 git
$ sudo apt-add-repository ppa:git-core/ppa
$ sudo apt-get update
$ sudo apt-get install git
5。设置环境变量更新代码
$ cd ~
$ mkdir bin
$ PATH=~/bin:$PATH
Download the Repo tool and ensure that it is executable:
$ curl https://dl-ssl.google.com/dl/googlesource/git-repo/repo > ~/bin/repo
$ chmod a+x ~/bin/repo
$ mkdir working
$ cd working
$ repo init -u https://android.googlesource.com/platform/manifest -b gingerbread-release
如果出错,按提示设置Email和用户名
$ repo sync
重复执行直至成功为止
6。编译 Android2.3 源代码
$ . build/envsetup.sh
$ lunch
$ make -j4
7。下载NDK并解压
8。下载 curl 并解压到 android 2.3 源代码 external 目录下,然后把目录改为 curl(Android惯例,不改也可以)
9。编译 CURL, 打开一个新的终端,执行
$ export NDK_ROOT=/YOUR/NDK/PATH
$ export
$ cd external/curl
$./configure --host=arm-linux-androideabi
#define HAVE_LIBSSL 1
#define HAVE_OPENSSL_CRYPTO_H 1
#define HAVE_OPENSSL_ERR_H 1
#define HAVE_OPENSSL_PEM_H 1
#define HAVE_OPENSSL_PKCS12_H 1
#define HAVE_OPENSSL_RSA_H 1
#define HAVE_OPENSSL_SSL_H 1
#define HAVE_OPENSSL_X509_H 1
#define USE_OPENSSL 1
#define USE_SSLEAY 1
设置source 编译环境,然后继续
$ cd ../..
$ . build/envsetup.h
$ lunch
$ cd external/curl/packet/Android
$ 修改Android.mk文件,在LOCAL_C_INCLUDES += $(LOCAL_PATH)/include/ 后添加
LOCAL_C_INCLUDES += $(LOCAL_PATH)/../openssl/include
把
LOCAL_SYSTEM_SHARED_LIBRARIES := libc libssl libcrypto
include $(BUILD_SHARED_LIBRARY)
$ mm
从 out 目录中找出 libcurl.so 使用
记得在JAVA代码中加上 System.loadLibrary(“curl”);
后记,折腾了好几天,走了无数弯路后,终于总结出了这些步骤,执行这些步骤后 libcurl.so 可以使用,但其SSL功能尚未调通,仍需继续努力
![在Android <wbr>2.3 <wbr>平台下编译CURL <wbr>和OpenSSL过程 在Android <wbr>2.3 <wbr>平台下编译CURL <wbr>和OpenSSL过程](https://i-blog.csdnimg.cn/blog_migrate/676ebda4729556d2ae74a2569eb85a7a.gif)