频道栏目
首页 > 程序开发 > 软件开发 > C++ > 正文
使用libpcap抓包编译错误
2013-03-16 13:29:16           
收藏   我要投稿
同样的程序从我fedora14上编译没问题,放到Fedora12上出现一大堆的错误,如下

[cpp]  

[root@root sias_catch]# make  

gcc -o jack_ip -g jack.c show_flow.c save_del.c -lpcap -lpthread  

In file included from jack.c:1:  

<span style="color:#ff0000;">jack.h:9:17: error: pcap.h: No such file or directory</span>  

In file included from jack.c:1:  

jack.h:81: warning: ‘struct pcap_pkthdr’ declared inside parameter list  

jack.h:81: warning: its scope is only this definition or declaration, which is probably not what you want  

jack.c:9: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘*’ token  

jack.c:32: warning: ‘struct pcap_pkthdr’ declared inside parameter list  

jack.c:32: error: conflicting types for ‘mycallback’  

jack.h:81: note: previous declaration of ‘mycallback’ was here  

jack.c: In function ‘mycallback’:  

jack.c:62: error: dereferencing pointer to incomplete type  

jack.c:63: error: dereferencing pointer to incomplete type  

jack.c:64: error: dereferencing pointer to incomplete type  

jack.c:135: error: dereferencing pointer to incomplete type  

jack.c:135: error: dereferencing pointer to incomplete type  

jack.c:159: error: dereferencing pointer to incomplete type  

jack.c:160: error: dereferencing pointer to incomplete type  

jack.c: In function ‘handler’:  

<span style="color:#ff0000;">jack.c:400: error: ‘pt’ undeclared (first use in this function)</span>  

jack.c:400: error: (Each undeclared identifier is reported only once  

jack.c:400: error: for each function it appears in.)  

jack.c: In function ‘main’:  

<span style="color:#ff0000;">jack.c:647: error: ‘PCAP_ERRBUF_SIZE’ undeclared (first use in this function)  

jack.c:648: error: ‘bpf_u_int32’ undeclared (first use in this function)</span>  

jack.c:648: error: expected ‘;’ before ‘mask’  

jack.c:649: error: expected ‘;’ before ‘subnet’  

jack.c:656: error: ‘pcap_if_t’ undeclared (first use in this function)  

jack.c:656: error: ‘alldevs’ undeclared (first use in this function)  

jack.c:657: error: ‘d’ undeclared (first use in this function)  

jack.c:658: error: ‘pcap_addr_t’ undeclared (first use in this function)  

jack.c:658: error: ‘a’ undeclared (first use in this function)  

jack.c:710: error: ‘subnet’ undeclared (first use in this function)  

jack.c:710: error: ‘mask’ undeclared (first use in this function)  

jack.c:740: error: ‘pt’ undeclared (first use in this function)  

In file included from save_del.c:3:  

<span style="color:#ff0000;">jack.h:9:17: error: pcap.h: No such file or directory</span>  

In file included from save_del.c:3:  

jack.h:81: warning: ‘struct pcap_pkthdr’ declared inside parameter list  

jack.h:81: warning: its scope is only this definition or declaration, which is probably not what you want  

make: *** [default] Error 1  

[root@root sias_catch]#  

从上面的错误可以看出来是头文件没包含进去的原因,但是用命令安装libpcap确实安装了啊!

[cpp]  

[root@root sias_catch]# yum install libpcap  

Loaded plugins: refresh-packagekit  

updates/metalink                                                                                                      | 4.0 kB     00:00       

Setting up Install Process  

Package 14:libpcap-1.0.0-4.20090922gite154e2.fc12.i686 already installed and latest version  

Nothing to do  

[root@root sias_catch]#   

 

然后就想到可能还有其他的没有安装!libpcap-devel

[cpp]  

[root@root sias_catch]# yum install libpcap-devel  

 

安装上,再编译下,成功了!

[cpp] 

[root@root sias_catch]# make  

gcc -o jack_ip -g jack.c show_flow.c save_del.c -lpcap -lpthread  

[root@root sias_catch]#   

 

 

点击复制链接 与好友分享!回本站首页
相关TAG标签 错误
上一篇:rqnoj 577 团伙
下一篇:面向对象2
相关文章
图文推荐
文章
推荐
点击排行

关于我们 | 联系我们 | 广告服务 | 投资合作 | 版权申明 | 在线帮助 | 网站地图 | 作品发布 | Vip技术培训 | 举报中心

版权所有: 红黑联盟--致力于做实用的IT技术学习网站