Quick Start - Windows and MinGW

This guide will help you install and build your first PcapPlusPlus application on Windows using MinGW32 / MinGW-w64 in a few simple steps.

Table of contents

  1. Step 1 - install PcapPlusPlus
  2. Step 2 - create your first app
  3. Step 3 - create a Makefile
  4. Step 4 - build and run your app

Step 1 - install PcapPlusPlus

Before installing PcapPlusPlus make sure you have the prerequisites installed for MinGW32 or MinGW-w64.

If you have MinGW with GCC version 5.3.0 or MinGW-w64 with GCC version 6.3.0 you can download a pre-compiled package from the v21.05 release page.

Otherwise you need to build PcapPlusPlus from source.

Step 2 - create your first app

If you downloaded a pre-compiled package go to: Drive:\path\to\your\package\example-app.

If you built it from source go to: Drive:\path\to\pcapplusplus\source\Tutorials\Tutorial-HelloWorld.

Make sure you see the following files:

 |-- main.cpp
 |-- 1_packet.pcap

main.cpp is the example application we’ll use.

1_packet.pcap is a pcap file the app reads from.

Step 3 - create a Makefile

If you downloaded a pre-compiled package you can find a Makefile in Drive:\path\to\your\package\example-app. This Makefile is already configured.

If you built it from source:

  • go to Drive:\path\to\pcapplusplus\source\Tutorials\Tutorial-HelloWorld
  • rename Makefile.windows to Makefile

Step 4 - build and run your app

Run make to build the app:

C:\path\to\example\app>mingw32-make.exe

An .exe file will be created which contains the compiled app. You can now run it and should be able to see the following output:

Source IP is '10.0.0.138'; Dest IP is '10.0.0.1'