Skip to main content
Version: v22.05

Build From Source on MacOS


In order to compile PcapPlusPlus on MacOS please make sure you have the following components installed:

  1. Xcode which contains all prerequisites required for PcapPlusPlus including gcc/g++ compiler and libpcap with all relevant header files

  2. Make sure you have Xcode Command Line Tools. You can install it by running the following command in Terminal:

    xcode-select --install
  3. PcapPlusPlus is available for both Intel and Apple silicon (M1) processors. To build for Apple silicon please use the --arm64 flag (please see below)

  4. OPTIONAL - install Zstd if you wish to enable PCAPNG streaming compression support:

    brew install zstd


Run the configuration script from PcapPlusPlus main directory:


This script has the following command-line switches (you can also view then by running ./ --help or ./ -h):

no switchesuse the default configuration
--use-immediate-modeuse libpcap immediate mode which enables getting packets as fast as possible (supported on libpcap>=1.5)
--set-direction-enabledset direction for capturing incoming or outgoing packets (supported on libpcap>=0.9.1)
--install-dirset a custom installation directory. Default is /usr/local
--libpcap-include-dirlibpcap header files directory. This parameter is optional and if omitted PcapPlusPlus will look for the header files in the default include paths
--libpcap-lib-dirlibpcap pre compiled lib directory. This parameter is optional and if omitted PcapPlusPlus will look for the lib file in the default lib paths
--use-zstduse Zstd for PCAPNG streaming compression. This parameter is optional
--arm64build for Apple Silicon M1 (arm64 architecture). This flag can be used for cross-compilation which means you can don't have to run the build on an Apple silicon M1 machine
-h, --helpdisplays a help message and exits. No further actions are performed

Here are a few examples:

Default configuration:


Configure PcapPlusPlus with libpcap's immediate mode:

./ --use-immediate-mode

Configure PcapPlusPlus with libpcap's set direction:

./ --set-direction-enabled

Provide non-standard paths for libpcap header and library files:

./ --libpcap-include-dir /home/myuser/my-libpcap/include --libpcap-lib-dir /home/myuser/my-libpcap/lib

Provide a custom installation directory:

./ --install-dir /home/myuser/my-install-dir

Use Zstd for pcapng compression:

./ --use-zstd

Build the code

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

  1. Run make or make 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 make libs instead of make all
  4. After compilation you can find the libraries, examples, header files and helpful makefiles under the Dist directory


After build is complete you can run the installation script which will copy the library and header files to the installation directory:

sudo make install

The default installation directory is /usr/local which means the header files will be copied to /usr/local/include/pcapplusplus and the library files will be copied to /usr/local/lib.

You can change the installation directory by using the --install-dir switch in the configuration script.

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.