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全部重新装一次就好了。 |
libpcap交叉编译
最新推荐文章于 2024-08-09 10:53:56 发布