首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > C语言 >

winpcap编程,该如何解决

2012-10-20 
winpcap编程#include pcap.hmain(){pcap_if_t *alldevspcap_if_t *dint i0char errbuf[PCAP_ERRBUF_

winpcap编程
#include "pcap.h" 
main() 

pcap_if_t *alldevs; 
pcap_if_t *d; 
int i=0; 
char errbuf[PCAP_ERRBUF_SIZE]; 
/* 取得列表 */ 
if (pcap_findalldevs(&alldevs, errbuf) == -1) 

fprintf(stderr,"Error in pcap_findalldevs: %s\n", errbuf); 
exit(1); 

/* 输出列表 */ 
for(d=alldevs;d;d=d->next) 

printf("%d. %s", ++i, d->name); 
if (d->description) 
printf(" (%s)\n", d->description); 
else 
/* Y- 没有有效的描述 */ 
printf(" (No description available)\n"); 

if(i==0) 

/* Y- 没有有效的接口, 可能是因为没有安装WinPcap */ 
printf("\nNo interfaces found! Make sure WinPcap is installed.\n"); 
return; 

/* 我们不再需要列表了, 释放 */ 
pcap_freealldevs(alldevs); 



出现这样的错误该怎么解决
pcap2.obj : error LNK2001: unresolved external symbol _pcap_freealldevs
pcap2.obj : error LNK2001: unresolved external symbol _pcap_findalldevs
Debug/pcap2.exe : fatal error LNK1120: 2 unresolved externals
谢谢啦

[解决办法]
没有加入库文件。
在程序里加入导入库:#progma comment(lib, "xxx.lib")

热点排行