使用libpcap抓包编译错误

同样的程序从我fedora14上编译没问题,放到Fedora12上出现一大堆的错误,如下

[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:
jack.h:9:17: error: pcap.h: No such file or directory
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’:
jack.c:400: error: ‘pt’ undeclared (first use in this function)
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’:
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)
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:
jack.h:9:17: error: pcap.h: No such file or directory
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确实安装了啊!

[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

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

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

[root@root sias_catch]# make
gcc -o jack_ip -g jack.c show_flow.c save_del.c -lpcap -lpthread
[root@root sias_catch]# 



评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值