您的位置:首页 > 其它

移植pcap库到ARM开发板

2010-10-23 21:59 281 查看
首先到http://www.tcpdump.org/上下载libpcap-0.9.4源代码 ,解压后进入目录,一下为具体的执行过程:

[root@olive libpcap-0.9.4]# ./configure --host=arm-linux
configure: error: pcap type not determined when cross-compiling; use --with-pcap=...

运行configure说交叉编译时没指定pcap类型,看了README文档,试了指定了几种类型,但configure时均出错!没办法了,只好采取暴力措施了,在configure脚本中注释掉检查交叉编译的部分,具体注释掉一下语句:

#if test -z "$with_pcap" && test "$cross_compiling" = yes; then
# { { echo "$as_me:$LINENO: error: pcap type not determined when cross-compiling; use --with-pcap=..." >&5
#echo "$as_me: error: pcap type not determined when cross-compiling; use --with-pcap=..." >&2;}
# { (exit 1); exit 1; }; }
#fi
.......
# if test $ac_cv_linux_vers = unknown ; then
# { { echo "$as_me:$LINENO: error: cannot determine linux version when cross-compiling" >&5
#echo "$as_me: error: cannot determine linux version when cross-compiling" >&2;}
# { (exit 1); exit 1; }; }
# fi

再次运行configure命令,这下终于OK!终于生成了Makefile.接下来make:

[root@olive libpcap-0.9.4]#make

居然没生成动态链接库,只有一个libpcap.a静态库.只好再修改它的Makefile.打开Makefile,找到了下面这个目标:

libpcap.so: $(OBJ)
@rm -f $@
ld -shared -o $@.`cat VERSION` $(OBJ)
把链接器ld该成arm-linux-ld,然后make此目标:

[root@olive libpcap-0.9.4]# make libpcap.so

这样便生成了动态库libpcap.so.0.9.4,可样就可以将此拷贝到Liod板的/lib/这个目录下,别忘了在再创建两个符号链接:
libpcap.so.0和libpcap.so.

此时便可以利用pcapTest这个小程序来测试一下了.测试OK,可以捕获网络数据包,终于大功告成!

06.5.19
21:00
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: