Quick Start - MacOS

This guide will help you install and build your first PcapPlusPlus application on MacOS 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 MacOS.

The easiest way to get PcapPlusPlus is from Homebrew:

brew install pcapplusplus

If you prefer not to use Homebrew you can also found pre-compiled packages for various versions of MacOS and Xcode in the v21.05 release page. After downloading and extracting the archive file go to: /path/to/your/package/ and run the installation script:

./install.sh

Another option is to build PcapPlusPlus from source. Make sure not to skip the installation part.

Step 2 - create your first app

If you installed PcapPlusPlus using Homebrew go to the Hello World tutorial on GitHub and get the files in that directory.

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

If you built it from source go to: /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 /path/to/your/package/example-app. This Makefile is already configured.

If you built it from source or downloaded it from GitHub:

  • go to the directory of the tutorial /path/to/pcapplusplus/source/Tutorials/Tutorial-HelloWorld
  • rename Makefile.non_windows to Makefile

Step 4 - build and run your app

Run make to build the app:

$ make

An executable 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'