Saturday, May 2, 2009

Porting cURL Library on LN2410

Introduction
cURL library allows you to connect and communicate to many different types of servers with many different types of protocols. libcurl currently supports the http, https, ftp, gopher, telnet, dict, file, and ldap protocols. libcurl also supports HTTPS certificates, HTTP POST, HTTP PUT, FTP uploading (this can also be done with PHP's ftp extension), HTTP form based upload, proxies, cookies, and user+password authentication.
In this section is about how to compile curl in the host
environment and put it them on target machine.

Configuration and Installation
Download and unpack the
cURL package.
Source code of cURL can be obtained from http://curl.haxx.se/download.html
'
cd' to the new directory. (e.g. cd curl-7.12.3)

Now call the configuration script,Be sure and specify the '--host' and
'--build' parameters at configuration time.
The following script is cross-compiling for ARM9 processor using the
cross tool chain 'cross-2.95.3.tar.bz2' on
RedHat Linux.
(Other tool chains has library linking issues)

./configure --prefix=/root/curl --build=i686-pc-linux-gnu --host=arm-linux --target=arm-linux CC=/usr/local/arm/2.95.3/bin/arm-linux-gcc
The '--prefix' parameter
specifies where
cURL will be installed.
CC parameter is the cross compiler toolchain path.
If 'configure' completes
successfully, do 'make' and 'make install' as usual.


Copying the binaries and libraries to root file system
Once the make install is sucessfull,copy the binaries and libraries in curl folder to bin and lib folder respectively on root file system.
now test the libary on the commad line by typing 'curl url'
I got html page as a response when I typed 'curl http://192.168.1.1' on the shell.

[root@test Linux]# curl http://192.168.1.1
401 Unauthorized401 Unauthorized401 Unauthorized401 Unauthorized







3 comments:

  1. Hello,

    I use fedora 1 and cross compile curl for ep9315.
    But I get a problem when I configure as your advice.
    I ran
    ./configure --prefix=/home/giangdo/charger/curl-7.10.6/output/ --build=i686-pc-linux-gnu --host=arm-linux --target=arm-linux CC=/usr/local/arm/3.4/bin/arm-linux-gcc --with-random=/dev/urandom

    It completed. Then I make, it's get errors.
    Please help me !

    Thanks a lot !
    ===========================================
    make
    Making all in lib
    make[1]: Entering directory `/home/giangdo/charger/curl-7.10.6/lib'
    cd . && \
    echo "/* The file is generated automaticly */" > ca-bundle.h
    echo '#undef CURL_CA_BUNDLE /* unknown */' >> ca-bundle.h
    make all-am
    make[2]: Entering directory `/home/giangdo/charger/curl-7.10.6/lib'
    if /bin/sh ../libtool --mode=compile /usr/local/arm/3.4/bin/arm-linux-gcc -DHAVE_CONFIG_H -I../include -I../lib -I../lib -g -O2 -MT url.lo -MD -MP -MF ".deps/url.Tpo" \
    -c -o url.lo `test -f 'url.c' || echo './'`url.c; \
    then mv ".deps/url.Tpo" ".deps/url.Plo"; \
    else rm -f ".deps/url.Tpo"; exit 1; \
    fi
    /usr/local/arm/3.4/bin/arm-linux-gcc -DHAVE_CONFIG_H -I../include -I../lib -I../lib -g -O2 -MT url.lo -MD -MP -MF .deps/url.Tpo -c url.c -fPIC -DPIC -o .libs/url.o
    /usr/local/arm/3.4/bin/arm-linux-gcc -DHAVE_CONFIG_H -I../include -I../lib -I../lib -g -O2 -MT url.lo -MD -MP -MF .deps/url.Tpo -c url.c -o url.o >/dev/null 2>&1
    if /bin/sh ../libtool --mode=compile /usr/local/arm/3.4/bin/arm-linux-gcc -DHAVE_CONFIG_H -I../include -I../lib -I../lib -g -O2 -MT mprintf.lo -MD -MP -MF ".deps/mprintf.Tpo" \
    -c -o mprintf.lo `test -f 'mprintf.c' || echo './'`mprintf.c; \
    then mv ".deps/mprintf.Tpo" ".deps/mprintf.Plo"; \
    else rm -f ".deps/mprintf.Tpo"; exit 1; \
    fi
    /usr/local/arm/3.4/bin/arm-linux-gcc -DHAVE_CONFIG_H -I../include -I../lib -I../lib -g -O2 -MT mprintf.lo -MD -MP -MF .deps/mprintf.Tpo -c mprintf.c -fPIC -DPIC -o .libs/mprintf.o
    mprintf.c:1103: error: parse error before "__extension__"
    mprintf.c:1103: error: parse error before '->' token
    make[2]: *** [mprintf.lo] Error 1
    make[2]: Leaving directory `/home/giangdo/charger/curl-7.10.6/lib'
    make[1]: *** [all] Error 2
    make[1]: Leaving directory `/home/giangdo/charger/curl-7.10.6/lib'
    make: *** [all-recursive] Error 1
    =================================================



    The config.log shows
    ===================================
    configure:2776: result: yes
    configure:2793: checking for /usr/local/arm/3.4/bin/arm-linux-gcc option to accept ANSI C
    configure:2854: /usr/local/arm/3.4/bin/arm-linux-gcc -c -g -O2 conftest.c >&5
    configure:2857: $? = 0
    configure:2860: test -s conftest.o
    configure:2863: $? = 0
    configure:2881: result: none needed
    configure:2899: /usr/local/arm/3.4/bin/arm-linux-gcc -c -g -O2 conftest.c >&5
    conftest.c:2: error: parse error before "me"
    configure:2902: $? = 1
    configure: failed program was:
    | #ifndef __cplusplus
    | choke me
    | #endif
    =========================

    ReplyDelete
  2. Try a higher vesrion curl source version, in my case curl-7.12.3 worked.

    ReplyDelete