Build From Source on Windows - MinGW-w64
Prerequisites
In order to compile PcapPlusPlus on Windows using MinGW-w64 you need the following components:
- Download and run MinGW-w64 installer from here: https://sourceforge.net/projects/mingw-w64/
- Make sure the installation path doesn't contain spaces (otherwise PcapPlusPlus compilation may fail)
- 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) - Follow the instruction in the installation wizard
- Install
MSYS2
from here: https://www.msys2.org/ - Add the following folders to your
PATH
environment variable:- 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
- The MSYS2
usr\bin
folder, for example:C:\msys32\usr\bin
- The MinGW-w64 folder that contains
- WinPcap developer's pack OR Npcap SDK - containing the
wpcap
library PcapPlusPlus is linking with plus relevanth
files.- WinPcap developer's pack can be downloaded from here: https://www.winpcap.org/devel.htm
- Npcap SDK can be downloaded from here: https://nmap.org/npcap/#download
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:
Option | Description |
---|---|
-m , --mingw-home | MinGW-w64 home directory (the folder that includes bin , lib and include directories) |
-s , --msys-home | MSYS or MSYS2 home directory |
-w , --pcap-sdk | Path to WinPcap Developer Pack (WpdPack) OR Npcap SDK |
-h , --help | Display 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:
- Run
mingw32-make.exe all
from PcapPlusPlus main directory - This should compile all libraries, unit-tests and examples
- To build the libraries only (without the unit-tests and examples) run
mingw32-make.exe libs
instead ofmingw32-make.exe all
- 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.