由于某个项目需要,需要得到本地路由的IP地址。在网上搜索了下,可以用命令curl ifconfig.me得到。结果在linux(arm11平台)中输入该命令结果not find。悲惨啊,这个命令在移植linux时没被加进去啊。得,看样子得自己移植了。首先得到curl相关源代码。然后大家可以参照这篇文章进行编译就可以得到curl执行文件,放到/bin目录下就行。注意修改交叉工具链的路径哦。
先开始libCurl的移植过程:
下载curl-7.20.0.tar.bz2解压至本目录,开始configure,由于之前一直发现配置不过,出现多次错误,这里直接给出正确的配置:
cd curl-7.20.0&& ./configure --prefix=/win/530/curl/build --build=i686-linux--host=arm-linux CC=/opt/timesys/toolchains/armv5l-linux/bin/armv5l-linux-gccCFLAGS='-Os' --enable-debug --enable-optimize --enable-static --disable-ftp--without-zlib --disable-rtsp --disable-dict --disable-proxy--disable-telnet --disable-tftp --disable-pop3 --disable-imap --disable-smtp --disable-ipv6 --enable-http -enable-crypto-auth --without-gnutls--without-nss --without-ca-bundle --with-random=/dev/urandom exportLDFLAGS="-static
-L/opt/timesys/toolchains/armv5l-linux/lib" &&
configure碰到的错误:
1.checking for "/dev/urandom"... configure: error: cannot check forfile existence when cross compiling
google后发现答案:
http://www.hiawatha-webserver.org/forum/topic/137
按照回答,由于是在主机上配置、编译,所以配置期间没找到适合于目标系统的随机数生成器,具体在/dev/urandom下面,但是我找了下,确实是有的:
[root@openssl]# ls -al/dev/urandom
crw-rw-rw- 1 root root 1, 9 Jan 12 17:12 /dev/urandom
[root@openssl]# file/dev/urandom
/dev/urandom: character special
引用回答的原文:
#You may need to provide a parameter like '--with-random=/dev/urandom' toconfigure as it cannot detect the presence of a random number generating devicefor a target system.
2.checking for curl_socklen_t data type... unknown
configure: error: cannot find data type for curl_socklen_t.
在网上找了多次,没找到解决方法。因为之前编译的时候使用到库一直没指定连接库,因为这个是有编译器自己自动连接的,最后灵机一动,想想给加上链接库试试:
LDFLAGS="-static-L/opt/timesys/toolchains/armv5l-linux/lib"
没想到无奈的问题解决了。
configure编译后的信息如下
#configure: Configuredto build curl/libcurl:
# curl version: 7.20.0
# Host setup: arm-unknown-linux-gnu
# Install prefix: /win/530/curl
# Compiler: /opt/timesys/toolchains/armv5l-linux/bin/armv5l-linux-gcc
# SSL support: enabled (OpenSSL)
# SSH support: no (--with-libssh2)
# zlib support: enabled
# krb4 support: no (--with-krb4*)
# GSSAPI support: no (--with-gssapi)
# SPNEGO support: no (--with-spnego)
# c-ares support: no (--enable-ares)
# ipv6 support: no (--enable-ipv6)
# IDN support: no (--with-libidn)
# Build libcurl: Shared=yes, Static=yes
# Built-in manual: enabled
# Verbose errors: enabled (--disable-verbose)
# SSPI support: no (--enable-sspi)
# ca cert bundle: no
# ca cert path: no
# LDAP support: no (--enable-ldap / --with-ldap-lib / --with-lber-lib)
# LDAPS support: no (--enable-ldaps)
# RTSP support: enabled
# Protocols: DICT FILE HTTP HTTPSRTSP
编译安装
make clean&&make && make install