Build From Source on FreeBSD
Prerequisites
In order to compile PcapPlusPlus on FreeBSD please make sure you have the following components installed:
git
(if not installed please run:pkg install git
)gsed
(if not installed please run:pkg install gsed
)gmake
(if not installed please run:pkg install gmake
)libpcap
(if not installed please run:pkg install libpcap
)
Configuration
Run the configuration script from PcapPlusPlus main directory:
./configure-freebsd.sh
This script has the following command-line switches (you can also view then by running ./configure-freebsd.sh --help
or ./configure-freebsd.sh -h
):
Option | Description |
---|---|
no switches | use the default configuration |
--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 |
--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-freebsd.sh
Configure PcapPlusPlus with libpcap's immediate mode:
./configure-freebsd.sh --use-immediate-mode
Configure PcapPlusPlus with libpcap's set direction:
./configure-freebsd.sh --set-direction-enabled
Provide non-standard paths for libpcap header and library files:
./configure-freebsd.sh --libpcap-include-dir /my-folder/my-libpcap/include --libpcap-lib-dir /my-folder/my-libpcap/lib
Provide a custom installation directory:
./configure-freebsd.sh --install-dir /my-folder/my-install-dir
Build the code
After running the config script, you're can safely build the code:
- Run
gmake
orgmake 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
gmake libs
instead ofgmake 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:
sudo gmake 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.