1.從ftp://ftp.gnu.org/gnu/下載flex、bison、GNU M4、libpcap安裝包,具體的鏈接分別如下:
flex下載:http://flex.sourceforge.net/或者https://github.com/westes/flex/releases
bison下載:ftp://ftp.gnu.org/gnu/bison/
GNU M4下載:ftp://ftp.gnu.org/gnu/m4/
libpcap下載:http://www.tcpdump.org/release/
2.將以上的四個壓縮包解壓並且移動到指定的文件夾中,使用命令:tar -zxvf ** + mv ** **
3.按照m4,bison,flex,libpcap的順序依次執行以下三條命令:
sudo ./configure
sudo make
sudo make install
(注:到此為止安裝libpcap結束,以下為測試是否安裝成功)
4.創建test.c文件:touch test.c,並且在文件中寫入:
#include <pcap.h>
#include <stdio.h>
int main()
{
char errBuf[PCAP_ERRBUF_SIZE], * device;
device = pcap_lookupdev(errBuf);
if(device)
{
printf("success: device: %s\n", device);
}
else
{
printf("error: %s\n", errBuf);
}
return 0;
}
}
5.輸入命令進行編譯:gcc -o test test.c -lpcap
6.運行test文件:./test

(注:當打印出如上信息即為配置成功。)
