Chinaunix首页 | 论坛 | 博客
  • 博客访问: 4521113
  • 博文数量: 356
  • 博客积分: 10458
  • 博客等级: 上将
  • 技术积分: 4734
  • 用 户 组: 普通用户
  • 注册时间: 2008-03-24 14:59
文章分类

全部博文(356)

文章存档

2020年(17)

2019年(9)

2018年(26)

2017年(5)

2016年(11)

2015年(20)

2014年(2)

2013年(17)

2012年(15)

2011年(4)

2010年(7)

2009年(14)

2008年(209)

分类: C/C++

2008-05-01 09:30:51

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{};".
阅读(2141) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~