命令编译安装:
./configure
make
make install
好了,顺利安完之后,编写测试代码 test.c 如下(也是Copy的):
#include<stdio.h>
int main()
{
char *dev, errbuf[1024];
dev=pcap_lookupdev(errbuf);
if(dev==NULL){
fprintf(stderr,"couldn't find default device: %s\n",errbuf);
return(2);
}
printf("Device: %s\n",dev);
return(0);
}
好了,编译这段代码: gcc -o test test.c -lpcap
执行: 执行的时候也因该以root身份  sudo su 输入密码
./test 执行生成的可执行文件test。好了,问题来了,提示:
error while loading shared libraries: libpcap.so.1: cannot open shared object file: No such file or directory
在这里卡了很久,在http://opensource.ask4itsolutions.com/forums/vglug-vibrant-gnulinux-user-group/libpcapso1-not-found 这里才找到了解决方法。

在/usr/local/lib目录下, libpcap.so.1文件就躺在这里,为什么找不到呢。

解决方法:打开 /etc目录下的文件ld.so.conf ,添加两行
/usr/local/lib
/usr/lib
然后在终端下执行从新加载配置的命令:
ldconfig

好了,再编译运行test.c成功输出结果:
Device: eth0
如果不以root身份执行,将会输出:
couldn't find default device: no suitable device found