# Build and install DPDK and Pktgen-DPDK
###### tags: `DAQ` `protoDUNE` `DUNE-DAQ`
## Local installation of DPDK
This is done on `np04-srv-021.cern.ch`.
```bash=
cd /scratch/pding
wget https://fast.dpdk.org/rel/dpdk-21.11.tar.xz
tar xvf dpdk-21.11.tar.xz
cd dpdk-21.11
meson build
ninja -C build
export DESTDIR=/scratch/pding/opt
cd build
meson install
```
Note that the setting of `DESTDIR` env is for `meson` to install the package locally, otherwise `sudo` is required and the package will be installed under `/usr/local`.
After the installation is complete, one will need to fix `pkg-config` files in the local installation since by default it has the `prefix=/usr/local`
Change the first line in both `/scratch/pding/opt/usr/local/lib64/pkgconfig/libdpdk-libs.pc` and `/scratch/pding/opt/usr/local/lib64/pkgconfig/libdpdk.pc` to be `prefix=/scratch/pding/opt/usr/local`
## Build `Pktgen-DPDK`
```bash=
cd /scratch/pding
git clone https://github.com/pktgen/Pktgen-DPDK.git
cd Pktgen-DPDK
git checkout pktgen-21.11.0 # Note: the version needs to match DPDK version here.
#
# Modify two `meson.build` files under `Pktgen-DPDK`.
# Changes can be found in the following `git diff` output
#
# Note the change in `app/meson.build` is not necessary if you do not have a system DPDK package installed by yum.
# This is to avoid picking up system DPDK which might be different than the one built/installed.
#
export PKG_CONFIG_PATH=/scratch/pding/opt/usr/local/lib64/pkgconfig:$PKG_CONFIG_PATH
meson build
ninja -C build
export DESTDIR=/scratch/pding/opt
cd build
meson install
```
```diff=
diff --git a/app/meson.build b/app/meson.build
index f8f5f5c..0badd08 100644
--- a/app/meson.build
+++ b/app/meson.build
@@ -27,10 +27,10 @@ if get_option('enable_gui')
cflags += '-DGUI'
endif
-deps += [cc.find_library('rte_net_i40e', required: false)]
-deps += [cc.find_library('rte_net_ixgbe', required: false)]
-deps += [cc.find_library('rte_net_ice', required: false)]
-deps += [cc.find_library('rte_bus_vdev', required: false)]
+deps += [cc.find_library('rte_net_i40e', dirs: [dpdk_libs_path], required: false)]
+deps += [cc.find_library('rte_net_ixgbe', dirs: [dpdk_libs_path], required: false)]
+deps += [cc.find_library('rte_net_ice', dirs: [dpdk_libs_path], required: false)]
+deps += [cc.find_library('rte_bus_vdev', dirs: [dpdk_libs_path], required: false)]
deps += [dependency('threads')]
deps += [cc.find_library('numa', required: true)]
diff --git a/lib/fgen/meson.build b/lib/fgen/meson.build
index 6cf7dcb..6da6664 100644
--- a/lib/fgen/meson.build
+++ b/lib/fgen/meson.build
@@ -3,5 +3,5 @@
sources = files('fgen.c', 'parse.c', 'unparse.c')
-libfgen = library('ften', sources, dependencies: common)
+libfgen = library('ften', sources, dependencies: [common, dpdk])
fgen = declare_dependency(link_with: libfgen, include_directories: include_directories('.'))
diff --git a/meson.build b/meson.build
index 3de9147..0117246 100644
--- a/meson.build
+++ b/meson.build
@@ -62,7 +62,7 @@ endif
dpdk = dependency('libdpdk', required: true)
# message('prefix: ' + get_option('prefix') + ' libdir: ' + get_option('libdir'))
-dpdk_libs_path = join_paths(get_option('prefix'), get_option('libdir'))
+dpdk_libs_path = dpdk.get_pkgconfig_variable('libdir')
# message('DPDK lib path: ' + dpdk_libs_path)
dpdk_bond = cc.find_library('librte_net_bond', dirs: [dpdk_libs_path], required: false)
```
