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

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