libCurl/openssl/Zlib的ARM移植

本人使用环境

Host linux(from ubuntu):

jeos[just enougth OS]

交叉编译器:

/opt/timesys/toolchains/armv5l-linux/bin/armv5l-linux-gcc

target Processor:

ARM926EJ-S rev 5 (v5l)

Hardware:

Atmel AT91SAM9260-EK

 

 

先开始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-gcc CFLAGS='-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 export LDFLAGS="-static
-L/opt/timesys/toolchains/armv5l-linux/lib" &&

 

configure碰到的错误:
1.checking for "/dev/urandom"... configure: error: cannot check for file 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' to configure as it cannot detect the presence of a random number generating device for 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: Configured to 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 HTTPS RTSP

编译安装

make clean &&make && make install

 

 

openssl

下载openssl-0.9.8m.tar.gz解压至本目录,开始configure:

./config --prefix=/win/530/curl/openssl/build  os/compiler:/opt/timesys/toolchains/armv5l-linux/bin/armv5l-linux-gcc

 

最开始使用:

CC=/opt/timesys/toolchains/armv5l-linux/bin/armv5l-linux-gcc CFLAGS='-Os' export LDFLAGS="-static -L/opt/timesys/toolchains/armv5l-linux/lib"

打死也编译不过去,本想改改config/Configure的,但是真的没法下手:写的太混乱了。比明朝晚期的朝廷还要O__O"…

后来找到一篇文章

http://wifihack.net/blog/tag/arm/

原来CC需要用os/compiler去指定的!晕倒,最开始在INSTALL里面看到这个选项还不以为然……

但是按照这个方法也不行:

/opt/timesys/toolchains/armv5l-linux/bin/armv5l-linux-gcc -I. -I.. -I../include -DOPENSSL_THREADS  -march=pentium    -c -o cryptlib.o cryptlib.c
cryptlib.c:1: error: bad value (pentium) for -march= switch

方法也挺简单的,起因是-march=pentium这个编译开关:

搜索Makefile,删掉这个信息即可。当然主要是这行:

CFLAG= -DOPENSSL_THREADS  -march=pentium

前面的都好像没用处,去掉不去掉都可以。

 

按照博主的说明,当然最后需要修改

AR= ar $(ARFLAGS) r

AR= /opt/timesys/toolchains/armv5l-linux/bin/armv5l-linux-ar $(ARFLAGS) r

不修改也编译的过去,估计连接的库是适合于x86的吧。

 

 到libcurl下载简单的c文件,写好Mikefile后,加载到目标机上运行:

# ./t
./t: error while loading shared libraries: libssl.so.5: cannot open shared object file: No such file or directory

我晕倒。。然后开始编译 ssl库见上面的编译方法。编译期间偶然在/opt/timesys/toolchains/armv5l-linux/armv5l-linux/lib找到了链接库

libssl.so         libssl.so.0.9.7f  libssl.so.5      

 

我晕。。估计是因为编译libcurl的时候没注意使用静态加载,本想拷贝他到目标机,让程序到当前目录加载的(默认的/lib /usr/lib都为只读),可惜依然没办法跑起来,随即修改

LDFLAGS="-static -L/opt/timesys/toolchains/armv5l-linux/lib"

LDFLAGS="-static -L/opt/timesys/toolchains/armv5l-linux/armv5l-linux/lib -static -lz -static -lssl"

再试试:

 

 

 

 

 

 

 

  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值