欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

在android中增加curl的解決方法

 更新時(shí)間:2013年06月15日 16:08:47   作者:  
本篇文章是對(duì)在android中增加curl的解決方法進(jìn)行了詳細(xì)的分析介紹,需要的朋友參考下

curl是一個(gè)著名的開(kāi)源文件傳輸協(xié)議實(shí)現(xiàn)軟件,其中包括了HTTP、HTTPS、FTP等多種常用不常用協(xié)議的實(shí)現(xiàn)。在curl最新版本的官方源代碼中其實(shí)已經(jīng)包括了android的編譯文件(Android.mk),不過(guò)要想編譯通過(guò)還需要做一些工作。

我所使用的curl版本是7.20.0,android源代碼版本是eclair 2.1。
首先將curl解壓到external目錄下,將目錄名稱改為curl(不改也可以,不過(guò)android的習(xí)慣是不帶版本號(hào),入鄉(xiāng)隨俗吧)。

(1) 首先要?jiǎng)?chuàng)建一個(gè)頭文件curl_config.h。創(chuàng)建方法在curl/Android.mk文件頭部的注釋里有說(shuō)明。根據(jù)這個(gè)說(shuō)明運(yùn)行configure。我所使用的命令行如下(我是編譯成x86版本的,不過(guò)我們的目的只是要生成curl_config.h文件,所以x86還是arm其實(shí)是一樣的):

復(fù)制代碼 代碼如下:

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找不到openssl,所以所生成的配置文件是不使用openssl的。要想使用ssl,需要手動(dòng)修改 lib/curl_config.h和src/curl_config.h,打開(kāi)宏定義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(但是注意android沒(méi)有編譯openssl中的 engine,因此不要打開(kāi)宏定義HAVE_OPENSSL_ENGINE_H),同時(shí)注釋掉宏定義HAVE_MALLOC_H和HAVE_IOCTL,這兩個(gè)宏定義在Android_config.h中有定義,不注釋的話在編譯過(guò)程中會(huì)有很多警告(但是能正確編譯通過(guò))

(3)修改curl/Android.mk文件,在LOCAL_C_INCLUDES變量的值中增加external/openssl/include,在 LOCAL_SYSTEM_SHARED_LIBRARIES變量的值中增加 libssl libz libcrypto。

好了現(xiàn)在可以編譯了:
make curl ONE_SHOT_MAKEFILE=external/curl/Android.mk TARGET_PRODUCT=<...>
 
不過(guò)上述Android.mk文件會(huì)將libcurl編譯為靜態(tài)庫(kù),要想編譯為動(dòng)態(tài)庫(kù)還需要修改一下Android.mk文件。

相關(guān)文章

最新評(píng)論