libpcap交叉编译

1.首先按照上一篇文章中的步骤建立交叉编译环境。
2.下载libpcap-1.0.0.tar.gz源码。
3.解压libpcap-1.0.0.tar.gz,cd进入目录,修改confiugre文件,把下面两段注释掉  
#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  
4. 确保你的系统已经安装了flex和bison(sudo apt-get install bison,sudo apt-get install flex)
,然后执行./configure --host=arm-linux,这样就会使用arm-linux-gcc进行configure,生成Makefile  
5. 修改Makefile的prefix项为prefix=/usr/local/arm/3.4.1/arm-linux,同时注意查看Makefile中的CC项,已经为arm-linux-gcc了。  
6. 接下来make,make install,完成了libpcap的编译和安装,查看/usr/local/arm/3.4.1/arm-linux/include,该目录下增加了三个pcap的文件库。
7.接着就可以用arm-linux-gcc编译你自己的抓包程序了。编译好的程序就可以在开发板上抓包了(注意在超级用户下运行),记得在用arm-linux-gcc编译时加上“-lpcap”选项。
---------------------------------------------------
第一次编译的时候如果有问题,若提示错误:undefined reference to `pcap_parse',将arm-linux-gcc和libpcap全部重新装一次就好了。
  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值