Main Page | Modules | Data Structures | File List | Data Fields | Globals | Related Pages

# How to compile WinPcap
[WinPcap internals]

This section explains how to compile WinPcap, both the kernel level and the user-level portion, on the various Win32 platforms. The source code can be found on the WinPcap website, at http://winpcap.polito.it/install/.

## Compiling the driver

Two main NPF sources are available for compilation: the Windows NTx one and the Windows 9x one. Note that, since the NPF Driver is platform dependent, it is STRONGLY suggested to compiled it on the OS where it will be used, in order to link the correct DDK libraries. For example, if you compile the driver with the Windows NT 4 DDK, it will not work properly in Windows 2000 and vice versa, also if the source code tree is the same.

### Compiling the driver on Windows NTx

Software requirements:

- Microsoft Driver Developer Kit (DDK) for NT for Windows 2000 or Windows XP
- A recent version of the Microsoft Platform Software Development Kit (SDK). If you encounter compilation problems, try to download the latest version from http://www.microsoft.com/msdownload/platformsdk/sdkupdate/
- Microsoft Visual C++ 6.0

If your system satisfies these requirements, follow these steps:

1. From the Window NT Start menu, select the folder Programs and then Development Kits, then Windows XXX DDK, where XXX is the target system. From here select the voice Checked Build Environment if you want to build a debug version, or Free Build Environment if you want to build a release version.
2. A command prompt will be opened. Move to the directory PacketNTx inside the WinPcap source folder and type the command
   CompileNT4, to build the driver for Windows NT 4
   or
   Compile2k, to build the driver for Windows NT 5 OSes, (like Windows 2000 or Windows XP)
   This commands will generate the driver (packet.sys), that will be put in the DDK output directory (usually \i386).

Warning: sometimes, during the compilation of the driver, a lot of 'last line incomplete' errors are generated. Ignore these errors and let the compilation process continue, they are due to bugs in some DDK versions.

### Compiling the driver on Windows 9x

To compile the driver there are the following software requirements:

- Driver Developer Kit (DDK) for Windows 95/98/ME
- A recent version of the Microsoft Platform Software Development Kit (SDK). If you encounter compilation problems, try to download the latest version from http://www.microsoft.com/msdownload/platformsdk/sdkupdate/
- Visual C++ 6.0

the steps to follow are:

1. Open a dos shell
2. Go to the VisualC++ BIN directory (for example C:\DEVSTUDIO\VC\BIN) and execute the command
   Vcvars32
3. Go to the SDK directory (for example C:\MSSDK) and execute the command
   Setenv sdk_path
   where sdk_path is the directory of SDK (for example Setenv C:\MSSDK)
4. Go to the DDK directory (for example C:\DDK) and execute the command
   Ddkenv 32 net
5. Move to the directory whit the driver's source code and type the command
   nmake rtl
   to obtain a release version, or
   nmake
   to obtain a debug version.
   The release version of packet.vxd will be placed in the retail directory, the debug version in the debug directory.

Warning: On some systems the NMAKE utility is not able to launch ADRC2VXD, this means that the driver binary is generated correctly, but without the copyright information. We don't know the cause of this problem.

## Compiling packet.dll

Like for NPF, two sources are available for compilation: the Windows NTx one and the Windows 9x one. They are located in PacketNTx\dll\ and in Packet9x\dll\.

Software requirements:

- A recent version of the Microsoft Platform Software Development Kit (SDK). If you encounter compilation problems, try to download the latest version from http://www.microsoft.com/msdownload/platformsdk/sdkupdate/
- Microsoft Visual C++ 6.0

To compile the PACKET.DLL, load the project contained in the directory PacketNTx\dll\project (or Packet9x\dll\project) in the Visual C++ IDE. There are four project configurations:

- PacketNT - Win32 Release: standard release configuration
- PacketNT - Win32 Debug: standard debug configuration
- PacketNT - Win32 NT4 Release: release configuration able to run on NT4 does not include Wan and IP helper API support.
- PacketNT - Win32 NT4 Debug: debug configuration able to run on NT4 does not include Wan and IP helper API support.
- WanPacket - Win32 Release: release version of the WanPacket library, used to interface with NetMon API for Wan capture
- WanPacket - Win32 Debug: debug version of the WanPacket library, used to interface with NetMon API for Wan capture

Choose the desired configuration and build the project to obtain the binary files.

## Compiling wpcap.dll

wpcap.dll can be compiled on any Win32 platform and the generated dll is system independent.

System Requirements:

- Microsoft Visual C++ 6.0 compiler
- A recent version of the Microsoft Platform Software Development Kit (SDK). If you encounter compilation problems, try to download the latest version from http://www.microsoft.com/msdownload/platformsdk/sdkupdate/

Project files are in the directory winpcap\wpcap\prj of the WinPcap source code distribution. Load wpcap.dsw from the Visual C++ IDE and build the program.
There are six build project configurations:

- Wpcap debug: no support for DAG cards and Remote capture, debug version
- Wpcap release: no support for DAG cards and Remote capture, release version
- Wpcap debug REMOTE: support for Remote capture, no support for DAG cards, debug version
- Wpcap release REMOTE: support for Remote capture, no support for DAG cards, release version
- Wpcap debug REMOTE DAG: support for both DAG cards and Remote capture, debug version
- Wpcap release REMOTE DAG: support for both DAG cards and Remote capture, release version

Both wpcap.lib and wpcap.dll will be put in the output folder related to a build configuration:

- Wpcap debug: winpcap\wpcap\prj\Debug
- Wpcap release: winpcap\wpcap\prj\Release
- Wpcap debug REMOTE: winpcap\wpcap\prj\Debug_REMOTE
- Wpcap release REMOTE: winpcap\wpcap\prj\Release_REMOTE
- Wpcap debug REMOTE DAG: winpcap\wpcap\prj\Debug_REMOTE_DAG
- Wpcap release REMOTE DAG: winpcap\wpcap\prj\Release_REMOTE_DAG

Note 1: wpcap.dll contains the source code of libpcap from www.tcpdump.org, with some modifications for remote capture. You will be able to include and build a different libpcap version simply copying it in the directory winpcap\wpcap\prj of the WinPcap source code distribution, but you must use the "Debug" or "Release" build configurations.
Note 2: the default project does not contain support for Endace Dag cards because, in order to compile wpcap.dll with Dag support, some include files from Dag software distribution are needed. These files are not public and must be requested to Endace (http://www.endace.com), which provides a source code tree with all the Dag source code. This tree must be put in a subfolder called dag of the winpcap folder. At this point, you can compile wpcap.dll with Dag support using the build configurations "Debug REMOTE DAG" and "Release REMOTE DAG".

documentation. Copyright (c) 2002-2003 Politecnico di Torino. All rights reserved.