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.

## Compiling the driver

Two main NPF source trees are available for compilation: Windows NTx and Windows 9x. Note that, since the NPF Driver is platform-dependent, it is STRONGLY suggested to compile 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 on Windows 2000 and vice versa.

### Compiling the driver on Windows NT4

Software requirements:

- Microsoft Driver Developer Kit (DDK) for Windows NT4
- A recent version of the Microsoft Platform Software Development Kit (SDK) that is compatible with Visual Studio 6 (the latest compatible one is Platform SDK February 2003). This version of the PSDK is available on the Microsoft web site at http://www.microsoft.com/msdownload/platformsdk/sdkupdate/psdk-full.htm. It can be ordered online at http://www.qmedia.ca/launch/psdk.htm, and it's also available to Microsoft MSDN subscribers on the Subscribers Downloads web site.
- Microsoft Visual C++ 6.0 with Service Pack 5 or 6 (both the service packs are available online on the Microsoft web site).

If your system satisfies these requirements, follow these steps:

1. From the Windows NT Start menu, select the folder Programs and then Development Kits, then Windows NT4 DDK. 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
   CompileDriver
   This script will generate the driver (npf.sys). The binary will be put in one of these folders
   - Free Build Environment: winpcap\PacketNTx\driver\bin\NT4\i386\free
   - Checked Build Environment: winpcap\PacketNTx\driver\bin\NT4\i386\checked

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 2000/XP/2003/Vista (32bit and 64bit AMD64)

Software requirements:

- Microsoft Driver Developer Kit (DDK) for Windows Windows XP or Windows Server 2003. As of WinPcap 4.0, the preferred DDK environment is "DDK for Windows Server 2003SP1", also known as DDK 3790.1830.

NOTE: it is possible to use older DDKs for Windows 2000, but you will need to manually modify the compilation scripts in order to disable PREfast (PREfast is a static code analysis tool shipped with recent versions of the DDK).

If your system satisfies these requirements, follow these steps:

1. From the Windows Start menu, select the folder Programs and then Development Kits, then Windows XXX DDK, where XXX is the target system, then Build Environments.
   - 32bit driver: Choose Windows 2000 and then Windows 2000 Free Build Environmentif you want to build a release version or Windows 2000 Checked Build Environment if you want to build a debug version .
   - 64bit AMD64 driver: Choose Windows Server 2003 and then Windows Server 2003 Free x64 Build Environment if you want to build a release version or Windows Server 2003 Checked x64 Build Environment if you want to build a debug version .
2. A command prompt will be opened. Move to the directory PacketNTx inside the WinPcap source folder and type the command
   CompileDriver
   This script will generate the driver (npf.sys). The binary will be put in one of these folders
   - 32bit driver (both Free and Checked Build): winpcap\PacketNTx\driver\bin\2k\i386
   - 64bit AMD64 driver (both Free and Checked Build): winpcap\PacketNTx\driver\bin\xp\amd64

### Compiling the driver on Windows 9x

NOTE: this Windows platform is no longer supported by WinPcap. However, the sources for these operating systems are still available in the sources package.

To compile the driver for Windows 9x you will need:

- Driver Developer Kit (DDK) for Windows 95/98/ME
- A recent version of the Microsoft Platform Software Development Kit (SDK) that is compatible with Visual Studio 6 (the latest compatible one is Platform SDK February 2003). This version of the PSDK is available on the Microsoft web site at http://www.microsoft.com/msdownload/platformsdk/sdkupdate/psdk-full.htm. It can be ordered online at http://www.qmedia.ca/launch/psdk.htm, and it's also available to Microsoft MSDN subscribers on the Subscribers Downloads web site.
- Microsoft Visual C++ 6.0 with Service Pack 5 or 6 (both the service packs are available online on the Microsoft web site).

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

The source tree for this DLL is located in PacketNTx\dll\.

NOTE: the 9x family of Windows operating systems is no longer supported by WinPcap. However, the sources for these operating systems are still available in the sources package.

Software requirements:

- A recent version of the Microsoft Platform Software Development Kit (SDK) that is compatible with Visual Studio 6 (the latest compatible one is Platform SDK February 2003). This version of the PSDK is available on the Microsoft web site at http://www.microsoft.com/msdownload/platformsdk/sdkupdate/psdk-full.htm. It can be ordered online at http://www.qmedia.ca/launch/psdk.htm, and it's also available to Microsoft MSDN subscribers on the Subscribers Downloads web site.
  Note: if you use Microsoft Visual Studio .NET the platform SDK is not needed to compile packet.dll.
- Microsoft Visual C++ 6.0 with Service Pack 5 or 6 (both the service packs are available online on the Microsoft web site).
- If you want to build WinPcap with the support for the CACE Technologies AirPcap wireless capture library, you will need to download the AirPcap developer's pack from http://www.cacetech.com/products/airpcap.htm. The AirPcap developer's pack needs to be unzipped in a folder in the same folder where the WinPcap sources have been unzipped.

To compile the PACKET.DLL, load the project contained in the directory PacketNTx\dll\project in the Visual C++ IDE. There are several project configurations:

- PacketNT - Win32 Release: standard release configuration
- PacketNT - Win32 Debug: standard debug configuration
- PacketNT - Win32 Release No AirPcap: standard release configuration, without AirPcap support
- PacketNT - Win32 Debug No AirPcap: standard debug configuration, without AirPcap support
- 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.
- PacketNT - Win32 Release Vista: release configuration able to run on Vista. It does not include Wan support (with the NetMon API).
- PacketNT - Win32 Debug Vista: debug configuration able to run on Vista. It does not include Wan support (with the NetMon API).
- 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 with Service Pack 5 or 6 (both the service packs are available online on the Microsoft web site).
- A recent version of the Microsoft Platform Software Development Kit (SDK) that is compatible with Visual Studio 6 (the latest compatible one is Platform SDK February 2003). This version of the PSDK is available on the Microsoft web site at http://www.microsoft.com/msdownload/platformsdk/sdkupdate/psdk-full.htm. It can be ordered online at http://www.qmedia.ca/launch/psdk.htm, and it's also available to Microsoft MSDN subscribers on the Subscribers Downloads web site.
  Note: if you use Microsoft Visual Studio .Net the platform SDK is not needed to compile wpcap.dll.
- 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.
- If you want to build WinPcap with the support for the CACE Technologies AirPcap wireless capture library, you will need to download the AirPcap developer's pack from http://www.cacetech.com/products/airpcap.htm. The AirPcap developer's pack needs to be unzipped in the same folder where the WinPcap sources have been unzipped.
  There are eight build project configurations:
  No support for Remore Capture, support for AirPcap, no support for DAG
- Wpcap debug: output folder winpcap\wpcap\prj\Debug
- Wpcap release: output folder winpcap\wpcap\prj\Release
  Support for Remore Capture, no support for AirPcap, no support for DAG
- Wpcap debug REMOTE NO AIRPCAP: output folder winpcap\wpcap\prj\Debug_REMOTE_NO_AIRPCAP
- Wpcap release REMOTE NO AIRPCAP: output folder winpcap\wpcap\prj\Release_REMOTE_NO_AIRPCAP

  Support for Remore Capture, support for AirPcap, no support for DAG

- Wpcap debug REMOTE: output folder winpcap\wpcap\prj\Debug_REMOTE
- Wpcap release REMOTE: output folder winpcap\wpcap\prj\Release_REMOTE
  Support for Remore Capture, support for AirPcap, support for DAG
- Wpcap debug REMOTE DAG: output folder winpcap\wpcap\prj\Debug_REMOTE_DAG
- Wpcap release REMOTE DAG: output folder winpcap\wpcap\prj\Release_REMOTE_DAG

Note: 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.