curl-library
Re: Porting libcurl on Android with SSL Support
Date: Thu, 5 Jul 2012 15:37:52 +0200
Hey dude..
The NDK is an opensource project,you can check it out at :
http://www.crystax.net/en/android/ndk
It's quite cool actually..
so back to the build stuff..
1. I the folder $NDK/toolchains I have the following tree structure :
.
|-- arm-linux-androideabi-4.4.3
| `-- prebuilt
| `-- linux-x86
| |-- arm-linux-androideabi
| |-- bin
| |-- include
| |-- lib
| `-- libexec
|-- arm-linux-androideabi-4.6.3
| |-- prebuilt
| | `-- linux-x86
| | |-- arm-linux-androideabi
| | |-- bin
| | |-- include
| | |-- lib
| | `-- libexec
| `-- sysroot
| `-- usr
| `-- local
|-- x86-4.4.3
| `-- prebuilt
| `-- linux-x86
| |-- bin
| |-- i686-android-linux
| |-- include
| |-- lib
| `-- libexec
`-- x86-4.6.3
`-- prebuilt
`-- linux-x86
|-- bin
|-- i686-android-linux
|-- include
|-- lib
`-- libexec
is this correct?
2. the script I'm using is actually just setting the environment and then
calling the curl config script, it's based on the explanations in the
Android.mk file comments by the dev team
here it is :
export A=/home/user/Development/AOSP/2.3.3
export CC=$A/prebuilt/linux-x86/toolchain/arm-eabi-4.2.1/bin/arm-eabi-gcc
export DASH=/home/user/Development/Projects/Android/MyCurl
export NDK=/home/user/Development/Tools/sdk/android/ndk
export NDKLIBS=$NDK/platforms/android-4/arch-arm/usr/include
export SYSROOT=$A/ndk/build/platforms/android-4/arch-arm
export CPPFLAGS="-I$A/external/openssl/include/
-I$A/external/openssl/crypto/-L$A/out/target/product/generic/obj/lib/
-I$A/system/core/include
-I$A/prebuilt/ndk/android-ndk-r4/platforms/android-4/arch-arm/usr/include/
-lz -lssl -lcrypto"
export CFLAGS="-I$A/external/openssl/include/ -I$A/external/openssl/crypto/
-L$A/out/target/product/generic/obj/lib/ -fno-exceptions -Wno-multichar
-mthumb -mthumb-interwork -nostdlib -lc -ldl -lm -march=armv5te
-mtune=xscale -msoft-float -mandroid -lz -fPIC -mthumb-interwork -mthumb
-mlong-calls -ffunction-sections -fstack-protector -fno-short-enums
-fomit-frame-pointer -fno-strict-aliasing -finline-limit=64
-D__ARM_ARCH_5__ -D__ARM_ARCH_5T__ -D__ARM_ARCH_5E__ -D__ARM_ARCH_5TE__
-DANDROID -DOS_ANDROID -D__NEW__ -D__SGI_STL_INTERNAL_PAIR_H
-I$SYSROOT/usr/include -I$A/system/core/include -I$NDKLIBS -lssl -lcrypto"
export LDFLAGS="-L$A/out/target/product/generic/obj/lib/
-L$A/out/target/product/generic/system/lib/-L$SYSROOT/usr/lib
-Wl,--gc-sections -nostdlib -lz -lc -lssl -lcrypto -lm -ldl -llog -lgcc
-Wl,--no-undefined,-z,nocopyreloc -Wl,-dynamic-linker,/system/bin/linker
-L$NDK/out/target/product/generic/obj/lib/
-L$DASH/jni/includes/precompiled/libssl/lib/"
./configure --host=arm-eabi --with-ssl=$A/external/openssl/include
In anycase .. the make install finished with the following result :
libtool: link: ranlib .libs/libcurl.a
libtool: link: ( cd ".libs" && rm -f "libcurl.la" && ln -s "../libcurl.la" "
libcurl.la" )
make[2]: Entering directory
`/home/user/Development/Projects/MyCurl/external/libcurl/jni/lib'
test -z "/usr/local/lib" || mkdir -p -- "/usr/local/lib"
/bin/bash ../libtool --mode=install /usr/bin/install -c 'libcurl.la'
'/usr/local/lib/libcurl.la'
libtool: install: /usr/bin/install -c .libs/libcurl.lai /usr/local/lib/
libcurl.la
/usr/bin/install: cannot create regular file `/usr/local/lib/libcurl.la':
Permission denied
make[2]: *** [install-libLTLIBRARIES] Error 1
make[2]: Leaving directory
`/home/tanco/Development/Projects/MyCurl/external/libcurl/jni/lib'
make[1]: *** [install-am] Error 2
make[1]: Leaving directory
`/home/tanco/Development/Projects/MyCurl/external/libcurl/jni/lib'
make: *** [install-recursive] Error 1
from what I can see, if I reached the cannot "create regular file
`/usr/local/lib/libcurl.la': Permission denied"
that I have a successful compile, and everything is in place, but when I do
an ndk-build, it fails with the same linker error as previously
Compile thumb : curl <= curl_gssapi.c
Compile thumb : curl <= curl_ntlm.c
Compile thumb : curl <= curl_ntlm_wb.c
In file included from libcurl/jni/lib/curl_ntlm_wb.c:37:
/home/tanco/Development/Tools/sdk/android/ndk/platforms/android-14/arch-arm/usr/include/unistd.h:
In function 'getpagesize':
/home/tanco/Development/Tools/sdk/android/ndk/platforms/android-14/arch-arm/usr/include/unistd.h:171:
warning: nested extern declaration of '__page_size'
/home/tanco/Development/Tools/sdk/android/ndk/platforms/android-14/arch-arm/usr/include/unistd.h:
In function '__getpageshift':
/home/tanco/Development/Tools/sdk/android/ndk/platforms/android-14/arch-arm/usr/include/unistd.h:175:
warning: nested extern declaration of '__page_shift'
Compile thumb : curl <= curl_ntlm_core.c
Compile thumb : curl <= curl_ntlm_msgs.c
StaticLibrary : libcurl.a
Executable : curly
libcurl/obj/local/armeabi/objs/curly/src/tool_paramhlp.o: In function
`checkpasswd':
libcurl/jni/src/tool_paramhlp.c:321: undefined reference to `getpass_r'
libcurl/obj/local/armeabi/libcurl.a(ssluse.o): In function
`Curl_ossl_close_all':
libcurl/jni/lib/ssluse.c:991: undefined reference to `ENGINE_finish'
libcurl/jni/lib/ssluse.c:992: undefined reference to `ENGINE_free'
libcurl/obj/local/armeabi/libcurl.a(ssluse.o): In function
`Curl_ossl_engines_list':
libcurl/jni/lib/ssluse.c:842: undefined reference to `ENGINE_get_first'
libcurl/jni/lib/ssluse.c:842: undefined reference to `ENGINE_get_next'
libcurl/jni/lib/ssluse.c:843: undefined reference to `ENGINE_get_id'
libcurl/obj/local/armeabi/libcurl.a(ssluse.o): In function
`Curl_ossl_set_engine_default':
libcurl/jni/lib/ssluse.c:817: undefined reference to `ENGINE_set_default'
libcurl/jni/lib/ssluse.c:818: undefined reference to `ENGINE_get_id'
libcurl/jni/lib/ssluse.c:822: undefined reference to `ENGINE_get_id'
libcurl/obj/local/armeabi/libcurl.a(ssluse.o): In function
`Curl_ossl_set_engine':
libcurl/jni/lib/ssluse.c:774: undefined reference to `ENGINE_by_id'
libcurl/jni/lib/ssluse.c:790: undefined reference to `ENGINE_finish'
libcurl/jni/lib/ssluse.c:791: undefined reference to `ENGINE_free'
libcurl/jni/lib/ssluse.c:794: undefined reference to `ENGINE_init'
libcurl/jni/lib/ssluse.c:797: undefined reference to `ENGINE_free'
libcurl/obj/local/armeabi/libcurl.a(ssluse.o): In function
`Curl_ossl_cleanup':
libcurl/jni/lib/ssluse.c:724: undefined reference to `ENGINE_cleanup'
libcurl/obj/local/armeabi/libcurl.a(ssluse.o): In function `Curl_ossl_init':
libcurl/jni/lib/ssluse.c:697: undefined reference to
`ENGINE_load_builtin_engines'
libcurl/obj/local/armeabi/libcurl.a(ssluse.o): In function `cert_stuff':
libcurl/jni/lib/ssluse.c:395: undefined reference to `ENGINE_ctrl'
libcurl/jni/lib/ssluse.c:402: undefined reference to `ENGINE_ctrl_cmd'
libcurl/obj/local/armeabi/libcurl.a(ssluse.o): In function
`ossl_connect_step1':
libcurl/jni/lib/ssluse.c:1629: undefined reference to
`SSL_CTX_set_srp_username'
libcurl/obj/local/armeabi/libcurl.a(ssluse.o): In function `cert_stuff':
libcurl/jni/lib/ssluse.c:554: undefined reference to
`ENGINE_load_private_key'
libcurl/obj/local/armeabi/libcurl.a(ssluse.o): In function
`ossl_connect_step1':
libcurl/jni/lib/ssluse.c:1633: undefined reference to
`SSL_CTX_set_srp_password'
collect2: ld returned 1 exit status
the thing is that, the static lib is built and is present, which I can see
from thiese few lines:
Compile thumb : curl <= curl_ntlm_core.c
Compile thumb : curl <= curl_ntlm_msgs.c
StaticLibrary : libcurl.a
Executable : curly
but unusable since if I include it in my build it tries to link with
openSSL's Engines which are still included in curl's build..
And that's where it hurts :)
Tancho
On Thu, Jul 5, 2012 at 3:12 PM, Guenter <lists_at_gknw.net> wrote:
> Hi Tancho,
> Am 05.07.2012 14:55, schrieb Tancho .:
>
> So if I understood correctly I am supposed to add stuff to the
>> standalone NDK.
>>
> yep.
>
> I am using Crystax NDK v7b (default google ndk with some extra stuff
>> like support for wchar_t and wstring, runtime_error, C++11 support
>> etc.. but it's completely backward compatible. )
>> so I extracted your zip in the following location
>>
>> $NDK_PATH/ndk/toolchains/arm-**linux-androideabi-4.4.3
>> the local folder was missing as you suggested, so I put it there. and
>>
> but I hope you did put it below:
> $NDK_PATH/ndk/toolchains/arm-**linux-androideabi-4.4.3/**sysroot/usr !
> so that you get:
> $NDK_PATH/ndk/toolchains/arm-**linux-androideabi-4.4.3/**
> sysroot/usr/local/include
> $NDK_PATH/ndk/toolchains/arm-**linux-androideabi-4.4.3/**
> sysroot/usr/local/lib
> ...
>
>
> also I set my Application.mk to use the 4.4.3 toolchain, next
>> $./androidconfig (the exported paths with the configure script that I
>> started this thread with)
>> and I got the same error?
>> did I miss something?
>>
> well, nothing can change if you still use a handcrafted script; you should
> instead use the standard configure script which comes with libcurl sources,
> and invoke it in libcurl top source dir like that:
> ./configure --host=arm-linux-androideabi --disable-shared --with-zlib
> --enable-ipv6 --without-librtmp
>
> optional add a --prefix=path so that you finally can call 'make install'
> to get a libcurl-devel package, and then after you got libcurl.a
> successfully compiled you can start to compile your jni ...
>
> BTW. is that jni written by you, or is it another opensource project?
>
>
> Gün.
>
>
>
> ------------------------------**------------------------------**-------
> List admin: http://cool.haxx.se/list/**listinfo/curl-library<http://cool.haxx.se/list/listinfo/curl-library>
> Etiquette: http://curl.haxx.se/mail/**etiquette.html<http://curl.haxx.se/mail/etiquette.html>
>
-------------------------------------------------------------------
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette: http://curl.haxx.se/mail/etiquette.html
Received on 2012-07-05