文章标题
2015-05-25 14:41
260 查看
winpcap 4.0.2
为了跑起来刚开始的例子
{
pcap_if_t *alldevs;
pcap_if_t *d;
int i=0;
char errbuf[PCAP_ERRBUF_SIZE];
}
首先,既然有了#include “pcap.h” 需要设置下文件包含,方法如下:
1.菜单Tool->Options->Directories选项卡->Show directories->Include files,选择WinPcap中的开发包目录中的Include目录
2.菜单Tool->Options->Directories选项卡->Show directories->Library files,选择WinPcap中的开发包目录中的Lib目录
*3.菜单Project->Settings->Link->Objects/library modules,按End键,输入” wpcap.lib”,注意wpcap.lib 前面有空格(或#pragma comment(lib,”wpcap.lib”) )
然后,编译出错,error C2065: ‘PCAP_SRC_IF_STRING’ : undeclared identifier,解决方法如下:
pcap.h中没有此函数,是在#include
为了跑起来刚开始的例子
include “pcap.h”
main(){
pcap_if_t *alldevs;
pcap_if_t *d;
int i=0;
char errbuf[PCAP_ERRBUF_SIZE];
/* 获取本地机器设备列表 */ if (pcap_findalldevs_ex(PCAP_SRC_IF_STRING, NULL /* auth is not needed */, &alldevs, errbuf) == -1) { fprintf(stderr,"Error in pcap_findalldevs_ex: %s\n", errbuf); exit(1); } /* 打印列表 */ for(d= alldevs; d != NULL; d= d->next) { printf("%d. %s", ++i, d->name); if (d->description) printf(" (%s)\n", d->description); else printf(" (No description available)\n"); } if (i == 0) { printf("\nNo interfaces found! Make sure WinPcap is installed.\n"); return; } /* 不再需要设备列表了,释放它 */ pcap_freealldevs(alldevs);
}
首先,既然有了#include “pcap.h” 需要设置下文件包含,方法如下:
1.菜单Tool->Options->Directories选项卡->Show directories->Include files,选择WinPcap中的开发包目录中的Include目录
2.菜单Tool->Options->Directories选项卡->Show directories->Library files,选择WinPcap中的开发包目录中的Lib目录
*3.菜单Project->Settings->Link->Objects/library modules,按End键,输入” wpcap.lib”,注意wpcap.lib 前面有空格(或#pragma comment(lib,”wpcap.lib”) )
然后,编译出错,error C2065: ‘PCAP_SRC_IF_STRING’ : undeclared identifier,解决方法如下:
pcap.h中没有此函数,是在#include