基于离线环境 CentOS 7.4 使用Meson & ninja 编译DPDK 20.11

CentOS 7.4 离线 编译安装 dpdk-20.11.2.tar.xz

离线准备:
内网机已经安装好 python3.
越来越多的环境依赖python3, CentOS 7系列 夕阳西下 越发明显.

资源要求:
可用内存大于 16G, 链接过程 耗内存.

外网获取 相关资源文件

1
chunli@ubuntu:~$ pip3 download meson       当前目录下会得到 meson-0.58.1.tar.gz,  传送至内网机

外网下载

1
https://github.com/ninja-build/ninja/releases 得到 ninja-linux.zip

解压DPDK

1
2
3
[root@localhost source]# tar  xf   dpdk-20.11.2.tar.xz
[root@localhost source]# cd dpdk-stable-20.11.2/
[root@localhost dpdk-stable-20.11.2]#

编译尝试:

1
2
3
4
5
[root@localhost dpdk-stable-20.11.2]# make
To build DPDK please use meson and ninja as described at
https://core.dpdk.org/doc/quick-start/
[root@localhost dpdk-stable-20.11.2]#
[root@localhost dpdk-stable-20.11.2]#

提示安装 meson ninja

安装 meson. 找到刚才传送过来的文件

1
2
3
4
[root@localhost pkg]# pip3 install meson-0.58.1.tar.gz
[root@localhost pkg]# meson --version #测试 meson
0.58.1
[root@localhost pkg]#

安装 ninja

1
2
3
4
[root@localhost pkg]# yum install ninja-build
[root@localhost pkg]# ninja --version #测试
1.7.2
[root@localhost pkg]#

重新登录, 刷新环境变量.

1
[root@localhost pkg]# logout

编译:

1
2
[root@localhost source]# cd dpdk-stable-20.11.2/
[root@localhost dpdk-stable-20.11.2]# meson build

报错:

1
2
3
4
5
6
7
8
9
10
ERROR: Could not detect Ninja v1.8.2 or newer
[root@localhost dpdk-stable-20.11.2]#
解决: 升级新版本 ninja
卸载旧版本
[root@localhost dpdk-stable-20.11.2]# yum autoremove -y ninja-build
[root@localhost ~]# unzip ninja-linux.zip
[root@localhost ~]# cp ninja /bin/
[root@localhost ~]# ninja --version
1.10.2
[root@localhost ~]#

继续编译:

1
2
3
4
[root@localhost source]# cd dpdk-stable-20.11.2/
[root@localhost dpdk-stable-20.11.2]# meson build
[root@localhost dpdk-stable-20.11.2]# meson -Dexamples=all build
[root@localhost dpdk-stable-20.11.2]# ninja -C build

编译结果:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
[root@localhost build]# ll -h examples/dpdk-*
-rwxr-xr-x 1 root root 18M Jul 18 15:52 examples/dpdk-bbdev_app
-rwxr-xr-x 1 root root 18M Jul 18 15:52 examples/dpdk-bond
-rwxr-xr-x 1 root root 18M Jul 18 15:52 examples/dpdk-cmdline
-rwxr-xr-x 1 root root 18M Jul 18 15:52 examples/dpdk-distributor
-rwxr-xr-x 1 root root 18M Jul 18 15:52 examples/dpdk-efd_node
-rwxr-xr-x 1 root root 18M Jul 18 15:52 examples/dpdk-efd_server
-rwxr-xr-x 1 root root 18M Jul 18 15:52 examples/dpdk-ethtool
-rwxr-xr-x 1 root root 18M Jul 18 15:52 examples/dpdk-eventdev_pipeline
-rwxr-xr-x 1 root root 18M Jul 18 15:52 examples/dpdk-fips_validation
-rwxr-xr-x 1 root root 18M Jul 18 15:52 examples/dpdk-flow_classify
-rwxr-xr-x 1 root root 18M Jul 18 15:52 examples/dpdk-flow_filtering
-rwxr-xr-x 1 root root 18M Jul 18 15:52 examples/dpdk-helloworld
-rwxr-xr-x 1 root root 18M Jul 18 15:52 examples/dpdk-hotplug_mp
-rwxr-xr-x 1 root root 18M Jul 18 15:52 examples/dpdk-ioat
-rwxr-xr-x 1 root root 18M Jul 18 15:52 examples/dpdk-ip_fragmentation
-rwxr-xr-x 1 root root 18M Jul 18 15:52 examples/dpdk-ip_pipeline
-rwxr-xr-x 1 root root 18M Jul 18 15:52 examples/dpdk-ip_reassembly
-rwxr-xr-x 1 root root 18M Jul 18 15:52 examples/dpdk-ipsec-secgw
-rwxr-xr-x 1 root root 18M Jul 18 15:52 examples/dpdk-ipv4_multicast
-rwxr-xr-x 1 root root 18M Jul 18 15:52 examples/dpdk-kni
-rwxr-xr-x 1 root root 18M Jul 18 15:52 examples/dpdk-l2fwd
-rwxr-xr-x 1 root root 18M Jul 18 15:52 examples/dpdk-l2fwd-crypto
-rwxr-xr-x 1 root root 18M Jul 18 15:52 examples/dpdk-l2fwd-event
-rwxr-xr-x 1 root root 18M Jul 18 15:52 examples/dpdk-l2fwd-jobstats
-rwxr-xr-x 1 root root 18M Jul 18 15:52 examples/dpdk-l2fwd-keepalive
-rwxr-xr-x 1 root root 18M Jul 18 15:52 examples/dpdk-l3fwd
-rwxr-xr-x 1 root root 18M Jul 18 15:52 examples/dpdk-l3fwd-acl
-rwxr-xr-x 1 root root 18M Jul 18 15:52 examples/dpdk-l3fwd-graph
-rwxr-xr-x 1 root root 18M Jul 18 15:52 examples/dpdk-l3fwd-power
-rwxr-xr-x 1 root root 18M Jul 18 15:52 examples/dpdk-l3fwd-thread
-rwxr-xr-x 1 root root 18M Jul 18 15:52 examples/dpdk-link_status_interrupt
-rwxr-xr-x 1 root root 18M Jul 18 15:52 examples/dpdk-mp_client
-rwxr-xr-x 1 root root 18M Jul 18 15:52 examples/dpdk-mp_server

`