Sunday, April 3, 2011

How to use pcap library in Borland C++Builder

[Compile]

1. In Borland C++Builder,  before you include pcap.h file, add the following codes.

#include "winsock2.h"
#define HAVE_U_INT8_T // for preventing Multiple declaration for 'int8_t'
#define WPCAP
#define HAVE_REMOTE
#include "pcap.h"

2. If you don't want to define HAVE_U_INT8_T, add the following codes in bittype.h.

#if SIZEOF_CHAR == 1
typedef unsigned char u_int8_t;
#ifndef __BORLANDC__
typedef signed char int8_t;
#endif // __BORLANDC__
#elif SIZEOF_INT == 1
typedef unsigned int u_int8_t;
#ifndef __BORLANDC__
typedef signed int int8_t;
#endif // __BORLANDC__
#else  /* XXX */
#error "there's no appropriate type for u_int8_t"
#endif


[Link]

In WinPcap/Lib folders, copy Packet.lib and wpcap.lib in any folders.

coff2omf Packet.lib Packet2007.lib
del Packet.lib
move Packet2007.lib Packet.lib




coff2omf wpcap.lib wpcap2007.lib
del wpcap.lib
move wpcap2007.lib wpcap.lib

No comments: