同樣的程序從我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]#