Build From Source on Windows - Visual Studio
Please visit the supported platforms page to see the Visual Studio versions currently supported in PcapPlusPlus.
Prerequisites
In order to build PcapPlusPlus on Windows with Visual Studio you need the following components:
- A supported version of Microsoft Visual Studio
- WinPcap developer's pack OR Npcap SDK - containing the wpcap library PcapPlusPlus is linking with plus relevant
h
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
- pthread-win32 - can be downloaded from here: ftp://sourceware.org/pub/pthreads-win32/pthreads-w32-2-9-1-release.zip
- In many cases you also need to download and install:
- Microsoft Visual C++ Redistributable for your version of Visual Studio
- Microsoft Visual C++ 2010 Redistributable
- OPTIONAL - download Zstd libraries if you wish to enable PCAPNG streaming compression support
Visual Studio project structure
After configuration is complete there are 3 Visual Studio solutions:
mk\[vs_version]\PcapPlusPlus.sln
- contains PcapPlusPlus libraries (Common++, Packet++ and Pcap++) and unit-tests projectsmk\[vs_version]\PcapPlusPlus-Examples.sln
- contains all PcapPlusPlus examples. RequiresPcapPlusPlus.sln
to be built firstmk\[vs_version]\Tutorials.sln
- contains all PcapPlusPlus tutorial examples. RequiresPcapPlusPlus.sln
to be built first
[vs_version]
?[vs_version]
can be either vs2015
, vs2017
or vs2019
and is determined during the configuration process.
All solutions support both 32-bit (x86) and 64-bit (x64) configurations as well as Debug and Release modes. So there are 4 supported modes:
x86|Debug
x86|Release
x64|Debug
x64|Release
Configuration
Before opening the solution (.sln
) files please run the configure-windows-visual-studio.bat
batch file from PcapPlusPlus main directory. This script configures the solution and project files according to the selected version of Visual Studio. It also creates a Visual Studio properties file called PcapPlusPlusPropertySheet.props
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
- Command line switches mode - all parameters are provided in the script command line
Wizard mode
In wizard mode the script will ask you for the requested version of Visual Studio and the locations of WinPcap developer's pack / Npcap SDK and pthreads-win32. Here is an example:
C:\PcapPlusPlus>configure-windows-visual-studio.bat
***********************************************
PcapPlusPlus Visual Studio configuration script
***********************************************
Choose Visual Studio version.
Currently supported options are: vs2015, vs2017 or vs2019: vs2019
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:\WpdPack
pthreads-win32 is required for compiling PcapPlusPlus.
If you didn't download it already, please download it from here: ftp://sourceware.org/pub/pthreads-win32/pthreads-w32-2-9-1-release.zip
Please specify pthreads-win32 path: C:\pthread-win32
PcapPlusPlus Visual Studio configuration is complete. Files created (or modified): PcapPlusPlusPropertySheet.props, Arping.vcxproj,
ArpSpoofing.vcxproj, Common++.vcxproj, DNSResolver.vcxproj, DnsSpoofing.vcxproj, HttpAnalyzer.vcxproj, IcmpFileTransfer-catcher.vcxproj,
IcmpFileTransfer-pitcher.vcxproj, IPDefragUtil.vcxproj, IPFragUtil.vcxproj, LightPcapNg.vcxproj, Packet++.vcxproj, Packet++Test.vcxproj,
Pcap++.vcxproj, Pcap++Test.vcxproj, PcapPrinter.vcxproj, PcapSearch.vcxproj, PcapSplitter.vcxproj, SSLAnalyzer.vcxproj, TcpReassembly.vcxproj,
Tutorial-HelloWorld.vcxproj, Tutorial-LiveTraffic.vcxproj, Tutorial-PacketCraftAndEdit.vcxproj, Tutorial-PacketParsing.vcxproj,
Tutorial-PcapFiles.vcxproj
Command line switches mode
In this mode you need to provide the requested Visual Studio version as well as the paths as script params. You can use the --help
switch to query these switches:
C:\PcapPlusPlus>configure-windows-visual-studio.bat --help
***********************************************
PcapPlusPlus Visual Studio configuration script
***********************************************
Help documentation for configure-windows-visual-studio.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-visual-studio.bat [-h] -v VS_VERSION -p PTHREADS_WIN32_DIR -w PCAP_SDK_DIR
The following switches are recognized:
-v|--vs-version --Set Visual Studio version to configure. Must be one of: vs2015, vs2017, vs2019
-p|--pthreads-home --Set pthreads-win32 home directory
-w|--pcap-sdk --Set WinPcap/Npcap SDK directory
-z|--zstd-sdk --Set ZStd SDK directory
-h|--help --Display this help message and exits. No further actions are performed
Here is an example:
C:\PcapPlusPlus>configure-windows-visual-studio.bat --vs-version 2019 --pcap-sdk C:\Npcap-SDK --pthreads-home C:\pthread-win32
***********************************************
PcapPlusPlus Visual Studio configuration script
***********************************************
PcapPlusPlus Visual Studio configuration is complete. Files created (or modified): PcapPlusPlusPropertySheet.props, Arping.vcxproj,
ArpSpoofing.vcxproj, Common++.vcxproj, DNSResolver.vcxproj, DnsSpoofing.vcxproj, HttpAnalyzer.vcxproj, IcmpFileTransfer-catcher.vcxproj,
IcmpFileTransfer-pitcher.vcxproj, IPDefragUtil.vcxproj, IPFragUtil.vcxproj, LightPcapNg.vcxproj, Packet++.vcxproj, Packet++Test.vcxproj,
Pcap++.vcxproj, Pcap++Test.vcxproj, PcapPrinter.vcxproj, PcapSearch.vcxproj, PcapSplitter.vcxproj, SSLAnalyzer.vcxproj, TcpReassembly.vcxproj,
Tutorial-HelloWorld.vcxproj, Tutorial-LiveTraffic.vcxproj, Tutorial-PacketCraftAndEdit.vcxproj, Tutorial-PacketParsing.vcxproj,
Tutorial-PcapFiles.vcxproj
Here are the available switches:
Option | Description |
---|---|
-v , --vs-version | Visual Studio version to configure. Currently supported versions are: vs2015 , vs2017 , vs2019 |
-p , --pthreads-home | pthreads-win32 home directory |
-w , --pcap-sdk | Path to WinPcap Developer Pack (WpdPack) OR Npcap SDK |
-z , --zstd-sdk | Path to Zstd SDK directory. This is an optional parameter that is required only if using Zstd for PCAPNG streaming compression |
-h , --help | Display the help message and exit. No further actions are performed |
Build the code
- Build
mk\[vs_version]\PcapPlusPlus.sln
first to get PcapPlusPlus libraries and unit-tests - Then you can choose to build
mk\[vs_version]\PcapPlusPlus-Examples.sln
to get PcapPlusPlus examples - You can also choose to build
mk\[vs_version]\Tutorials.sln
to see the tutorial examples
You can build these 3 solutions using either Visual Studio IDE or MSBuild
.
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.