Chinaunix首页 | 论坛 | 博客
  • 博客访问: 5708510
  • 博文数量: 675
  • 博客积分: 20301
  • 博客等级: 上将
  • 技术积分: 7671
  • 用 户 组: 普通用户
  • 注册时间: 2005-12-31 16:15
文章分类

全部博文(675)

文章存档

2012年(1)

2011年(20)

2010年(14)

2009年(63)

2008年(118)

2007年(141)

2006年(318)

分类: C/C++

2006-10-15 21:39:57

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{};".

阅读(1833) | 评论(0) | 转发(0) |
0

上一篇:VS中MSVCP80D问题

下一篇:解析#pragma指令(zz)

给主人留下些什么吧!~~