Using cURL in Android

后端 未结 7 608
终归单人心
终归单人心 2020-11-27 14:58

I would like to use cURL library in my android application in native code (using NDK r5b, the latest). After researching online, it seems the only way to use cURL in android

7条回答
  •  佛祖请我去吃肉
    2020-11-27 15:09

    After check all possibles post about this, I finally got a good compilation using a Linux x64 machine and Curl version 7.37.0 at path ${android-ndk-r10}.

    Maybe this steps can help you:

    ${android-ndk-r10}/build/tools/make-standalone-toolchain.sh --platform=android-15 --arch=armv7-a --toolchain=arm-linux-androideabi-4.8 --install-dir=./tmp/android-15
    

    export CC="${android-ndk-r10}/external/curl/tmp/android-15/bin/arm-linux-androideabi-gcc"
    

    ./configure --host=arm-linux --enable-cross-compile --enable-threaded-resolver --disable-shared --disable-ftp --disable-file --disable-ldap --disable-ldaps --disable-rtsp --disable-dict --disable-telnet --disable-tftp --disable-pop3 --disable-imap --disable-smtp --disable-gopher --disable-manual --enable-proxy --enable-ipv6 --enable-cookies --enable-symbol-hiding --disable-versioned-symbols --disable-soname-bump --disable-sspi --disable-ntlm-wb --prefix=${android-ndk-r10}/external/curl/build/curl-7.37.0
    

    make -j4
    

    make install
    

    You will get a build version at ${android-ndk-r10}/external/curl/build/curl-7.37.0.

    If you are using a 64bits machine to compile, maybe 2 defines are bad, and you get this error:

    error: size of array '__curl_rule_01__' is negative
    

    I solve redefining the variables in file ${CurlbuildAndroid}/include/curl/curlbuild.h (Its dangerous to do this, but it worked!):

    CURL_SIZEOF_LONG 4
    CURL_TYPEOF_CURL_OFF_T 4
    

提交回复
热议问题