error C2065: ‘pcap_open’ : undeclared identifier

发布于 2020-05-05  61 次阅读


问题描述:

错误:

1.cpp

E:Program FilesMicrosoft Visual StudioMyProjectswinpcap31.cpp(55) : error C2065: ‘pcap_open’ : undeclared identifier

E:Program FilesMicrosoft Visual StudioMyProjectswinpcap31.cpp(57) : error C2065: ‘PCAP_OPENFLAG_PROMISCUOUS’ : undeclared identifier

E:Program FilesMicrosoft Visual StudioMyProjectswinpcap31.cpp(61) : error C2440: ‘=’ : cannot convert from ‘int’ to ‘struct pcap *’

       Conversion from integral type to pointer type requires reinterpret_cast, C-style cast or function-style cast

E:Program FilesMicrosoft Visual StudioMyProjectswinpcap31.cpp(86) : error C2065: ‘time_t’ : undeclared identifier

E:Program FilesMicrosoft Visual StudioMyProjectswinpcap31.cpp(86) : error C2146: syntax error : missing ‘;’ before identifier ‘local_tv_sec’

E:Program FilesMicrosoft Visual StudioMyProjectswinpcap31.cpp(86) : error C2065: ‘local_tv_sec’ : undeclared identifier

E:Program FilesMicrosoft Visual StudioMyProjectswinpcap31.cpp(90) : error C2065: ‘localtime’ : undeclared identifier

E:Program FilesMicrosoft Visual StudioMyProjectswinpcap31.cpp(90) : error C2440: ‘=’ : cannot convert from ‘int’ to ‘struct packet_handler::tm *’

       Conversion from integral type to pointer type requires reinterpret_cast, C-style cast or function-style cast

E:Program FilesMicrosoft Visual StudioMyProjectswinpcap31.cpp(91) : error C2065: ‘strftime’ : undeclared identifier

执行 cl.exe 时出错.

原因:有些头文件没有加进来,所以会有错误。

 

解决办法:

因为winpcap现在增加了远程捕获的功能,

在pcap_findalldevs_ex和pcap_open函数中增加了远程主机身份验证的参数struct   pcap_rmtauth   *     auth,所以将两个函数的定义转移到remote-ext.h中去了

所以现在使用这两个参数的时候需要包含

#include   “remote-ext.h ”

#include “time.h”


一沙一世界,一花一天堂。君掌盛无边,刹那成永恒。