2.2. Building and Installing DPDK from Sources
This chapter provides a comprehensive guide for building DPDK from sources. It covers the necessary steps, prerequisites, and considerations for different architectures and compilers.
2.2.1. Required Tools
To build DPDK, you’ll need the following tools:
A C compiler like
gcc(version 5+) orclang(version 3.6+)pkg-configorpkgconfPython 3.6 or later
meson(version 0.57.0) andninjapyelftools(version 0.22+)
2.2.2. Platform-Specific Tool Installation
2.2.2.1. Linux
2.2.2.1.1. Alpine
sudo apk add alpine-sdk bsd-compat-headers gcc pkg-config python3 meson ninja pyelftools numactl-dev
2.2.2.1.2. Debian, Ubuntu, and derivatives
sudo apt install build-essential gcc pkg-config python3 meson ninja pyelftools libnuma-dev
2.2.2.1.3. Fedora and RedHat Enterprise Linux (RHEL)
sudo dnf groupinstall "Development Tools"
sudo dnf install gcc pkg-config python3 meson ninja python3-pyelftools numactl-devel
2.2.2.1.4. openSUSE
sudo zypper install -t pattern devel_basis
sudo zypper install gcc pkg-config python3 meson ninja python3-pyelftools libnuma-devel
2.2.2.2. FreeBSD
pkg install pkgconf python3 meson ninja pyelftools
Note
If you’re using FreeBSD, make sure kernel sources are included during the FreeBSD installation.
2.2.2.3. Windows System Requirements
Building the DPDK and its applications on Windows requires one of the following environments:
The Clang-LLVM C compiler and Microsoft MSVC linker.
The MinGW-w64 toolchain (either native or cross).
The Meson Build system is used to prepare the sources for compilation with the Ninja backend.
2.2.2.3.1. Option 1: Clang-LLVM C Compiler and Microsoft MSVC Linker
Install the Compiler: Download and install the Clang compiler from the LLVM website.
Install the Linker: Download and install the Build Tools for Visual Studio from the Microsoft website. When installing build tools, select the “Visual C++ build tools” option and make sure the Windows SDK is selected.
2.2.2.3.2. Option 2: MinGW-w64 Toolchain
On Linux (for cross-compilation): Install MinGW-w64 via a package manager. Version 4.0.4 for Ubuntu 16.04 cannot be used due to a MinGW-w64 bug.
On Windows: Obtain the latest version installer from the MinGW-w64 repository. Any thread model (POSIX or Win32) can be chosen, DPDK does not rely on it. Install to a folder without spaces in its name, like
C:\MinGW. This path is assumed for the rest of this guide.
2.2.2.4. Install the Build System
Download and install the build system from the Meson website. A good option to choose is the MSI installer for both meson and ninja together. Required version is Meson 0.57.x (baseline).
2.2.3. Getting the DPDK Source
2.2.3.1. Linux and FreeBSD
wget https://fast.dpdk.org/rel/dpdk-20.11.tar.xz
tar -xJf dpdk-20.11.tar.xz
cd dpdk-20.11
2.2.3.2. Windows
Download the DPDK source code from DPDK’s official website or clone the repository using a Git client. Extract the downloaded archive, if applicable, and navigate to the DPDK directory.
Navigate to the directory where the DPDK source code is located:
cd C:\path\to\dpdk-20.11
2.2.4. Building DPDK
Note
In all examples below, “build” is used as the name of the build directory. It is not part of the command itself.
2.2.4.1. Linux and FreeBSD
meson setup build
meson compile -C build
2.2.4.2. Windows
Option 1: Using Clang-LLVM
set CC=clang
meson setup -Dexamples=helloworld build
meson compile -C build
Option 2: Using MinGW-w64
set PATH=C:\MinGW\mingw64\bin;%PATH%
meson setup -Dexamples=helloworld build
meson compile -C build
Note
For detailed information on Meson build configuration options specific to DPDK, see DPDK Meson Build Configuration Options.
2.2.5. Cross-Compilation Instructions for Different Architectures
For instructions on building DPDK for ARM64, LoongArch, and RISC-V, refer to Cross-compiling DPDK for Different Architectures on Linux.