Build From Source on Linux
Table of contents
Prerequisites
In order to compile PcapPlusPlus on Linux please make sure you have the following components installed:
-
libpcap developers pack - contains the libpcap library PcapPlusPlus is linking with and relevant the header files. You can download it from http://www.tcpdump.org/#latest-release or through the standard Linux package managers such as
apt-get
oryum
:sudo apt-get install libpcap-dev
or:
sudo yum install libpcap-devel
-
libstdc++-static
package. If it’s not already installed you can install it usingapt-get
oryum
-
OPTIONAL - download and install Zstd if you wish to enable PCAPNG streaming compression support
Configuration
Run the configuration script from PcapPlusPlus main directory:
./configure-linux.sh
Ths script has two modes of operation:
- Wizard mode - the script will walk you through the configuration parameters to provide
- Params mode - provide the different parameters using command-line switches
In general there are several types of configuration:
- With libpcap only
- With DPDK
- With PF_RING
Let’s cover the different options. We’ll begin with the wizard mode and later cover the params mode.
Wizard mode
This mode is pretty much self explanatory and the wizard will guide you through the parameters you need to provide:
seladb@seladb:~/PcapPlusPlus$ ./configure-linux.sh
****************************************
PcapPlusPlus Linux configuration script
****************************************
Number of arguments: 0
Compile PcapPlusPlus with PF_RING? y
Enter PF_RING source path: /home/seladb/PF_RING
Compile PcapPlusPlus with DPDK? y
Enter DPDK source path: /home/seladb/dpdk-18.11
PcapPlusPlus configuration is complete. Files created (or modified): mk/platform.mk, mk/PcapPlusPlus.mk, mk/install.sh, mk/uninstall.sh
seladb@seladb:~/PcapPlusPlus$
Command-line switches mode
You an view all available switches by running ./configure-linux.sh --help
or ./configure-linux.sh -h
:
--default |
use the default configuration. This assumes libpcap-dev is installed |
--dpdk |
setup PcapPlusPlus with DPDK. When using this switch you must also set --dpdk-home |
--dpdk-home |
set DPDK home directory. Use only when --dpdk is set |
--pf-ring |
setup PcapPlusPlus with PF_RING. When using this switch you must also set --pf-ring-home |
--pf-ring-home |
sets PF_RING home directory. Use only when --pf-ring is set |
--use-immediate-mode |
use libpcap immediate mode which enables getting packets as fast as possible (supported on libpcap>=1.5) |
--set-direction-enabled |
set direction for capturing incoming or outgoing packets (supported on libpcap>=0.9.1) |
--install-dir |
set a custom installation directory. Default is /usr/local |
--libpcap-include-dir |
libpcap header files directory. This parameter is optional and if omitted PcapPlusPlus will look for the header files in the default include paths |
--use-zstd |
use Zstd for PCAPNG streaming compression. This parameter is optional |
--libpcap-lib-dir |
libpcap pre compiled lib directory. This parameter is optional and if omitted PcapPlusPlus will look for the lib file in the default lib paths |
-h , --help |
displays a help message and exits. No further actions are performed |
Here are a few examples:
Default configuration:
./configure-linux.sh --default
Configure PcapPlusPlus with DPDK:
./configure-linux.sh --dpdk --dpdk-home /home/myuser/dpdk-18.11
Configure PcapPlusPlus with PF_RING:
./configure-linux.sh --pf-ring --pf-ring-home /home/myuser/PF_RING
Configure PcapPlusPlus with libpcap’s immediate mode:
./configure-linux.sh --use-immediate-mode
Configure PcapPlusPlus with libpcap’s set direction:
./configure-linux.sh --set-direction-enabled
Provide non-standard paths for libpcap header and library files:
./configure-linux.sh --libpcap-include-dir /home/myuser/my-libpcap/include --libpcap-lib-dir /home/myuser/my-libpcap/lib
Provide a custom installation directory:
./configure-linux.sh --install-dir /home/myuser/my-install-dir
Use Zstd for pcapng compression:
./configure-linux.sh --use-zstd
Build the code
After running the config script, you’re can safely build the code:
- Run
make
ormake 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
make libs
instead ofmake all
- After compilation you can find the libraries, examples, header files and helpful makefiles under the
Dist
directory
Installation
After build is complete you can run the installation script which will copy the library and header files to the installation directory:
seladb@seladb:~/PcapPlusPlus$ sudo make install
Installation complete!
seladb@seladb:~/PcapPlusPlus$
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.