Winpcap的Manual上的一些例子无法运行,查看FAQ就可以得到答案
Q-23: If I try to compile my application using the new pcap APIs provided in WinPcap 3.1beta, the compiler fails with "warning C4013: 'pcap_???' undefined" or "error C2065: 'PCAP_OPENFLAG_????' : undeclared identifier". What's the problem?
A: The following new pcap APIs provided in WinPcap 3.1beta work only if "HAVE_REMOTE" is defined:
* pcap_open()
* pcap_findalldevs_ex()
* pcap_createsrcstr()
* pcap_parsesrcstr()
* pcap_setsampling()
* pcap_remoteact_accept()
* pcap_remoteact_list()
* pcap_remoteact_close()
* pcap_remoteact_cleanup()
You can define HAVE_REMOTE
* in your source/header files, with #define HAVE_REMOTE, before including pcap.h
* through a compiler/project option
Q-29: Whenever I try to create a WinPcap-based application with Visual Studio.NET 2002 or later, I get the error "TypeLoadException, Could not load type pcap".
A: You are using Managed C++ (i.e. you executable is targeted to the .NET CLR, Common Language Runtime).
The problem is due to the fact that the standard winpcap include file "pcap.h" contains only a forward declaration of "struct pcap", but not the actual definition of it. As a consequence, the Managed C++ compiler does not emit any metadata for that type, since there's no definition for it.
There are two solutions to the problem:
1. Include "pcap-int.h" instead of "pcap.h". This include the actual definition for the type "struct pcap"
2. Add a fake definition of "struct pcap". The simplest one is "struct pcap{};".
阅读(2124) | 评论(0) | 转发(0) |