Skip to main content
Version: v22.11

Build From Source on Windows - MinGW-w64

Prerequisites

In order to compile PcapPlusPlus on Windows using MinGW-w64 you need the following components:

  1. Download and run MinGW-w64 installer from here: https://sourceforge.net/projects/mingw-w64/
  2. Make sure the installation path doesn't contain spaces (otherwise PcapPlusPlus compilation may fail)
  3. Make sure to choose the i686 (32-bit) and POSIX threads (and not win32 threads) options. for example: i686-8.1.0-posix-dwarf-rt_v6-rev0. PcapPlusPlus doesn't support MinGW-w64 64-bit (x86_64)
  4. Follow the instruction in the installation wizard
  5. Install MSYS2from here: https://www.msys2.org/
  6. Add the following folders to your PATH environment variable:
    1. The MinGW-w64 folder that contains g++.exe, mingw32-make, etc. It should be under [MinGW-w64_install_folder]\mingw32\bin, for example: C:\i686-8.1.0-posix-dwarf-rt_v6-rev0\mingw32\bin
    2. The MSYS2 usr\bin folder, for example: C:\msys32\usr\bin
  7. WinPcap developer's pack OR Npcap SDK - containing the wpcap library PcapPlusPlus is linking with plus relevant h files.
    1. WinPcap developer's pack can be downloaded from here: https://www.winpcap.org/devel.htm
    2. Npcap SDK can be downloaded from here: https://nmap.org/npcap/#download
x64 is not supported

Please notice that x64 compilation is not supported (and will not work) on MinGW-w64!

Configuration

Run the configure-windows-mingw.bat batch file from PcapPlusPlus main directory. The script creates a makefile mk\PcapPlusPlus.mk that contains paths for 3rd-party libraries being used to build PcapPlusPlus.

Ths script has two modes of operation:

  • Wizard mode - the script will walk you through the paths and parameters you need to provide
  • Params mode - all parameters are provided in the script command line

In wizard mode the script will ask you for MinGW-w64 location (for example: C:\i686-8.1.0-posix-dwarf-rt_v6-rev0) and also for WinPcap developer's pack / Npcap SDK location (for example: C:\WpdPack or C:\Npcap-SDK).

Here is an example of running the script:

******************************************
PcapPlusPlus Windows configuration script
******************************************

If mingw-w64 is not installed, please download and install it from here:
https://www.mingw-w64.org/downloads/#mingw-builds

Please specify mingw-w64 installed path (for example: C:\i686-8.1.0-posix-dwarf-rt_v6-rev0): C:\i686-8.1.0-posix-dwarf-rt_v6-rev0


MSYS2 is required for compiling PcapPlusPlus.
If MSYS2 are not installed, please download and install it from: https://www.msys2.org/

Please specify MSYS2 installed path: C:\msys64


WinPcap or Npcap SDK is required for compiling PcapPlusPlus.
For downloading WinPcap SDK (developer's pack) please go to https://www.winpcap.org/devel.htm
For downloading Npcap SDK please go to https://nmap.org/npcap/#download

Please specify WinPcap/Npcap SDK path: C:\Npcap-SDK

PcapPlusPlus configuration is complete. Files created (or modified): mk\platform.mk, mk\PcapPlusPlus.mk

In params mode you need to provide these paths as script params. You can use the --help switch to query these params:

C:\PcapPlusPlus>configure-windows-mingw.bat --help

******************************************
PcapPlusPlus Windows configuration script
******************************************


Help documentation for configure-windows-mingw.bat
This script has 2 modes of operation:
1) Without any switches. In this case the script will guide you through using wizards
2) With switches, as described below

Basic usage: configure-windows-mingw.bat [-h] -m MINGW_HOME_DIR -s MSYS_HOME_DIR -w PCAP_SDK_DIR

The following switches are recognized:
-m|--mingw-home --Set mingw-w64 home directory (the folder that includes "bin", "lib" and "include" directories)
-s|--msys-home --Set MSYS2 home directory
-w|--pcap-sdk --Set WinPcap/Npcap SDK directory
-h|--help --Display this help message and exits. No further actions are performed

For example:

C:\PcapPlusPlus>configure-windows-mingw.bat --mingw-home C:\i686-8.1.0-posix-dwarf-rt_v6-rev0 --msys-home C:\msys64 --pcap-sdk C:\WpdPack

******************************************
PcapPlusPlus Windows configuration script
******************************************


PcapPlusPlus configuration is complete. Files created (or modified): mk\platform.mk, mk\PcapPlusPlus.mk

Here are the available switches:

OptionDescription
-m , --mingw-homeMinGW-w64 home directory (the folder that includes bin, lib and include directories)
-s , --msys-homeMSYS or MSYS2 home directory
-w , --pcap-sdkPath to WinPcap Developer Pack (WpdPack) OR Npcap SDK
-h , --helpDisplay the help message and exit. No further actions are performed

Build the code

After running the config script, you're can safely build the code:

  1. Run mingw32-make.exe all from PcapPlusPlus main directory
  2. This should compile all libraries, unit-tests and examples
  3. To build the libraries only (without the unit-tests and examples) run mingw32-make.exe libs instead of mingw32-make.exe all
  4. After compilation you can find the libraries, examples, header files and helpful makefiles under the Dist\ directory

Running tests

PcapPlusPlus contains a set of test-cases you can run to make sure that everything works correctly on your system. This guide contains detailed instructions on how to run them.