libcurl equivalent?

730 views
Skip to first unread message

Paton Lewis

unread,
Apr 3, 2009, 7:45:11 PM4/3/09
to android-ndk
Does Android have support for libcurl (or an equivalent) that would
allow C++ clients to make HTTP requests via Android? WebKit appears to
have at least a partial implementation of some CURL APIs, but they
don't appear to be availble for use by third-party code.

Thank you,
Pat

Tom Bova

unread,
Apr 3, 2009, 10:12:16 PM4/3/09
to andro...@googlegroups.com
Pat,

I have got version 7.18.2 of libcurl built for android and have used it successfully.

I uploaded the Android.mk, curl.h and hostip.h files to the upload section of the android-ndk group page.  curl.h and hostip.h are slightly modified for the originals in the curl source.

Download version 7.18.2 of curl under the external directory of your build tree and put these files in the lib subdirectory of curl.  This should let you build libcurl.so

- Tom
--
Xtone Networks
P 703.318.1679
C 703.203.0382
www.xtone.com
___________________________________________
The information transmitted herewith is sensitive and confidential information intended only for use by the individual or entity to which it is addressed. If the reader of this message is not the intended recipient, you are hereby notified that any review, retransmission, dissemination, distribution, copying or other use of, or taking of any action in reliance upon this information is strictly prohibited. If you have received this communication in error, please contact the sender by reply email and destroy all copies of the original message and attached materials from your computer.


Paton Lewis

unread,
Apr 8, 2009, 3:11:22 PM4/8/09
to android-ndk
Thank you, Tom. However, we would rather not have to install a
facility that Android clearly already must implement internally. I am
still hoping to hear from someone at Google about how third-party C++
applications are expected to access libcurl-like functionality in
Android.

Thanks again,
Pat

On Apr 3, 7:12 pm, Tom Bova <tb...@xtone.com> wrote:
> Pat,
>
> I have got version 7.18.2 of libcurl built for android and have used it
> successfully.
>
> I uploaded the Android.mk, curl.h and hostip.h files to the upload section
> of the android-ndk group page.  curl.h and hostip.h are slightly modified
> for the originals in the curl source.
>
> Download version 7.18.2 of curl under the external directory of your build
> tree and put these files in the lib subdirectory of curl.  This should let
> you build libcurl.so
>
> - Tom
>

Dianne Hackborn

unread,
Apr 8, 2009, 3:47:23 PM4/8/09
to andro...@googlegroups.com
You can use JNI calls to use the official Java APIs.  Since Android is a Java-based system, this is going to be the solution for many things in at least the initial NDK.
--
Dianne Hackborn
Android framework engineer
hac...@android.com

Note: please don't send private questions to me, as I don't have time to provide private support, and so won't reply to such e-mails.  All such questions should be posted on public forums, where I and others can see and answer them.

Neeraj

unread,
Jun 30, 2009, 11:18:31 AM6/30/09
to Tom Bova, andro...@googlegroups.com
Dear Tom,

I tried following your steps for adding libcurl to Android, but I am
getting following errors,

make: execvp: /bin/bash: Argument list too long
target thumb C: libcurl <= external/curl-7.18.2/lib/speedcheck.c
In file included from external/curl-7.18.2/lib/setup.h:49,
from external/curl-7.18.2/lib/speedcheck.c:24:
external/curl-7.18.2/lib/config.h:323:1: warning: "HAVE_MALLOC_H"
redefined
In file included from <command-line>:0:
./system/core/include/arch/linux-arm/AndroidConfig.h:202:1: warning:
this is the location of the previous definition
In file included from external/curl-7.18.2/lib/setup.h:49,
from external/curl-7.18.2/lib/speedcheck.c:24:
external/curl-7.18.2/lib/config.h:582:1: warning: "HAVE_TERMIO_H"
redefined
In file included from <command-line>:0:
./system/core/include/arch/linux-arm/AndroidConfig.h:92:1: warning:
this is the location of the previous definition
In file included from external/curl-7.18.2/lib/setup_once.h:59,
from external/curl-7.18.2/lib/setup.h:374,
from external/curl-7.18.2/lib/speedcheck.c:24:
bionic/libc/include/time.h:92: warning: function declaration isn't a
prototype
In file included from out/target/product/generic/obj/include/curl/
curl.h:1809,
from external/curl-7.18.2/lib/speedcheck.c:29:
out/target/product/generic/obj/include/curl/multi.h:132: error:
expected declaration specifiers or '...' before 'fd_set'
out/target/product/generic/obj/include/curl/multi.h:133: error:
expected declaration specifiers or '...' before 'fd_set'
out/target/product/generic/obj/include/curl/multi.h:134: error:
expected declaration specifiers or '...' before 'fd_set'
In file included from external/curl-7.18.2/lib/urldata.h:110,
from external/curl-7.18.2/lib/speedcheck.c:30:
external/curl-7.18.2/lib/hostip.h:103:5: warning: #warning including
arpa/inet.h
make: *** [out/target/product/generic/obj/SHARED_LIBRARIES/
libcurl_intermediates/speedcheck.o] Error 1

If you could please guide me on where I am going wrong with this
integration.

Thanks and Regards,
Neeraj


On Apr 3, 10:12 pm, Tom Bova <tb...@xtone.com> wrote:
> Pat,
>
> I have got version 7.18.2 of libcurl built for android and have used it
> successfully.
>
> I uploaded the Android.mk, curl.h and hostip.h files to the upload section
> of the android-ndk group page.  curl.h and hostip.h are slightly modified
> for the originals in the curl source.
>
> Download version 7.18.2 of curl under the external directory of your build
> tree and put these files in the lib subdirectory of curl.  This should let
> you build libcurl.so
>
> - Tom
>

Tom Bova

unread,
Jun 30, 2009, 11:32:40 AM6/30/09
to Neeraj, andro...@googlegroups.com
Neeraj,

Check your config.h for both the lib and executable, do you have the following defined:

#define SELECT_TYPE_ARG234 fd_set *

Also in lib/hostip.h, I had to add the following


Index: hostip.h
===================================================================
--- hostip.h    (revision 15880)
+++ hostip.h    (working copy)
@@ -99,6 +99,11 @@
 #define ares_destroy(x) do {} while(0)
 #endif
 
+#ifdef ANDROID
+   #warning including arpa/inet.h
+   #include <arpa/inet.h>
+#endif
+

Give that a try.

- Tom

Neeraj

unread,
Jun 30, 2009, 2:40:00 PM6/30/09
to android-ndk
Dear Tom,

#define SELECT_TYPE_ARG234 fd_set * is defined in lib/config.h,
Also added the patch you provided in lib/hostip.h. But still getting
the same error.

Regards,
Neeraj

On Jun 30, 11:32 am, Tom Bova <tb...@xtone.com> wrote:
> Neeraj,
>
> Check your config.h for both the lib and executable, do you have the
> following defined:
>
> #define SELECT_TYPE_ARG234 fd_set *
>
> Also in lib/hostip.h, I had to add the following
>
> Index: hostip.h
> ===================================================================
> --- hostip.h    (revision 15880)
> +++ hostip.h    (working copy)
> @@ -99,6 +99,11 @@
>  #define ares_destroy(x) do {} while(0)
>  #endif
>
> +#ifdef ANDROID
> +   #warning including arpa/inet.h
> +   #include <arpa/inet.h>
> +#endif
> +
>
> Give that a try.
>
> - Tom
>

Guru Prasad

unread,
Jul 24, 2009, 1:29:02 AM7/24/09
to android-ndk
Hi Neeraj,

With the help of Tom, I figured out the issue.
File to be modified is: curl.h (under include/curl/).

Please append the line #67 in curl.h with the followings:
|| defined(ANDROID)

This modification will include <sys/select.h> for Android build.
The cause of the problem was this header file was not getting included
in the Android build. This was the reason for fd_set errors.

I have also uploaded curl.h to the android-ndk group page. So, along
with the files uploaded by Tom, this file also should be used for curl
build for Android.
Thanks to Tom Bova for everything.

Regards,
Guru Prasad
> > > > I uploaded the Android.mk,curl.h and hostip.h files to the upload
> > > section
> > > > of the android-ndk group page.  curl.h and hostip.h are slightly modified
> > > > for the originals in thecurlsource.
>
> > > > Download version 7.18.2 ofcurlunder the external directory of your
> > > build
> > > > tree and put these files in the lib subdirectory ofcurl.  This should
> > > let
> > > > you build libcurl.so
>
> > > > - Tom
>
> > > > On Fri, Apr 3, 2009 at 7:45 PM, Paton Lewis <pale...@adobe.com> wrote:
>
> > > > > Does Android have support for libcurl (or an equivalent) that would
> > > > > allow C++ clients to make HTTP requests via Android? WebKit appears to
> > > > > have at least a partial implementation of someCURLAPIs, but they

Kapil

unread,
Sep 17, 2009, 10:48:59 AM9/17/09
to android-ndk
Hi ,
I am new to Android. I compiled the libcurl as per you
mentioned.
My App runs fine till I does not include libcurl.so in my make file.
But after linking libcurl to my native code via android-ndk it is
giving error msg :
Unable to dlopen (/data/data/cap.rss/lib/libCap_RssTicker.so): Cannot
find library
I am not able to figure out where am I going wrong or am I missing any
thing??
It would be a great help If anybody can share the steps to link curl
in native code via ndk.

Following is my Android.mk for my App :

#######################
LOCAL_PATH := $(call my-dir)
SDK_BASE := /media/disk/linux_data/Downloads/Anroid_old/
Android_Master/
include $(CLEAR_VARS)

LOCAL_MODULE := My_App
LOCAL_SRC_FILES := My_App.c
LOCAL_LDLIBS := -L /root/Android/android-ndk-1.5_r1/build/platforms/
android-1.5/arch-arm/usr/lib/ \
-L apps/My_App/libs/ -llog \
-lstdc++ -nostdlib -Bdynamic \
-L$(SDK_BASE)/out/target/product/generic/obj/lib -lcurl \
-Wl,-rpath-link=$(SDK_BASE)/out/target/product/generic/system/lib
LOCAL_CFLAGS := -rdynamic -fPIC -I /media/disk/linux_data/Downloads/
Android_Master/external/curl-7.18.2/include
include $(BUILD_SHARED_LIBRARY)
######################

Thanx
~Kapil
> > > > I tried following your steps for addinglibcurlto Android, but I am
> > > > > I have got version 7.18.2 oflibcurlbuilt for android and have used it
> > > > > successfully.
>
> > > > > I uploaded the Android.mk,curl.h and hostip.h files to the upload
> > > > section
> > > > > of the android-ndk group page.  curl.h and hostip.h are slightly modified
> > > > > for the originals in thecurlsource.
>
> > > > > Download version 7.18.2 ofcurlunder the external directory of your
> > > > build
> > > > > tree and put these files in the lib subdirectory ofcurl.  This should
> > > > let
> > > > > you buildlibcurl.so
>
> > > > > - Tom
>
> > > > > On Fri, Apr 3, 2009 at 7:45 PM, Paton Lewis <pale...@adobe.com> wrote:
>
> > > > > > Does Android have support forlibcurl(or anequivalent) that would
Reply all
Reply to author
Forward
0 new messages