dpdk 编译helloworld报错:Makefile:14: *** “no installation of DPDK found“。 停止。

2,248 阅读1分钟

本文已参与[新人创作礼]活动,一起开启掘金创作之路

dpdk 编译helloworld报错

前言

环境与目录

[root@bogon helloworld]# pwd
/home/kira/dpdk-21.08/examples/helloworld

出错位置

[kira@bogon helloworld]$ make
Makefile:14: *** "no installation of DPDK found"。 停止。
[kira@bogon helloworld]$

分析

Makefile 14行报错,先看看Makefile文件

vi Makefile
1 # SPDX-License-Identifier: BSD-3-Clause
2 # Copyright(c) 2010-2014 Intel Corporation
3 
4 # binary name
5 APP = helloworld
6 
7 # all source are stored in SRCS-y
8 SRCS-y := main.c
9 
10 PKGCONF ?= pkg-config
11 
12 # Build using pkg-config variables if possible
13 ifneq ($(shell $(PKGCONF) --exists libdpdk && echo 0),0)
14 $(error "no installation of DPDK found")
15 endif
16 

是在shell执行 pkg-config --exists libdpdk的时候报错,shell返回为空

手动执行下试试,确实是这样

[root@bogon helloworld]# pkg-config --exists libdpdk
[root@bogon helloworld]#

看一下pkg-config是个什么东东,参考 博客园 pkg-config 详解 啊,原来是帮忙看编译时候一堆库之类的存放位置的,命令行敲一下有帮助 (写笔记时候libdpdk已经正常,拿dpdk来试一下)

[kira@bogon ~]$ pkg-config 
Must specify package names on the command line
[kira@bogon ~]$ pkg-config dpdk --libs
Package dpdk was not found in the pkg-config search path.
Perhaps you should add the directory containing `dpdk.pc'
to the PKG_CONFIG_PATH environment variable
No package 'dpdk' found
[kira@bogon ~]$ 

问题定位

通过上面的流程,知道了是 pkg-config 找不到 libdpdk, 参考 官网部署文档,英文 的说明,是有 libdpdk.pc 这个文件的 官网文档节选:

3.2.4. Building Applications Using Installed DPDK When installed system-wide, DPDK provides a pkg-config file libdpdk.pc for applications to query as part of their build. It’s recommended that the pkg-config file be used, rather than hard-coding the parameters (cflags/ldflags) for DPDK into the application build process.

An example of how to query and use the pkg-config file can be found in the Makefile of each of the example applications included with DPDK. A simplified example snippet is shown below, where the target binary name has been stored in the variable (APP)andthesourcesforthatbuildarestoredin(APP) and the sources for that build are stored in (SRCS-y).

那么,定位下这个文件,其实在系统目录里已经有了,是 pkg-config 没有找到这个文件

[kira@bogon helloworld]$ sudo find / -name "libdpdk.pc"
[sudo] kira 的密码:
/usr/local/lib64/pkgconfig/libdpdk.pc
/home/kira/dpdk-21.08/build/meson-private/libdpdk.pc
/home/kira/dpdk-21.08/clean/meson-private/libdpdk.pc
[kira@bogon helloworld]$

参考 pkg-config libdpdk --libs这个命令的提示,我们需要把这个文件的搜索路径放到 PKG_CONFIG_PATH这个环境变量里来,试一下

[kira@bogon helloworld]$ export PKG_CONFIG_PATH="/usr/local/lib64/pkgconfig/"
[kira@bogon helloworld]$ pkg-config libdpdk --libs
-Wl,--as-needed -L/usr/local/lib64 -lrte_node -lrte_graph -lrte_bpf -lrte_flow_classify -lrte_pipeline -lrte_table -lrte_port -lrte_fib -lrte_ipsec -lrte_vhost -lrte_stack -lrte_security -lrte_sched -lrte_reorder -lrte_rib -lrte_regexdev -lrte_rawdev -lrte_pdump -lrte_power -lrte_member -lrte_lpm -lrte_latencystats -lrte_kni -lrte_jobstats -lrte_ip_frag -lrte_gso -lrte_gro -lrte_eventdev -lrte_efd -lrte_distributor -lrte_cryptodev -lrte_compressdev -lrte_cfgfile -lrte_bitratestats -lrte_bbdev -lrte_acl -lrte_timer -lrte_hash -lrte_metrics -lrte_cmdline -lrte_pci -lrte_ethdev -lrte_meter -lrte_net -lrte_mbuf -lrte_mempool -lrte_rcu -lrte_ring -lrte_eal -lrte_telemetry -lrte_kvargs

好了,看起来 pkg-config的问题正常了,再重新试一下编译

[kira@bogon helloworld]$ su
密码:
[root@bogon helloworld]# make
cc -O3 -include rte_config.h -march=native -I/usr/local/include   -DALLOW_EXPERIMENTAL_API main.c -o build/helloworld-shared  -Wl,--as-needed -L/usr/local/lib64 -lrte_node -lrte_graph -lrte_bpf -lrte_flow_classify -lrte_pipeline -lrte_table -lrte_port -lrte_fib -lrte_ipsec -lrte_vhost -lrte_stack -lrte_security -lrte_sched -lrte_reorder -lrte_rib -lrte_regexdev -lrte_rawdev -lrte_pdump -lrte_power -lrte_member -lrte_lpm -lrte_latencystats -lrte_kni -lrte_jobstats -lrte_ip_frag -lrte_gso -lrte_gro -lrte_eventdev -lrte_efd -lrte_distributor -lrte_cryptodev -lrte_compressdev -lrte_cfgfile -lrte_bitratestats -lrte_bbdev -lrte_acl -lrte_timer -lrte_hash -lrte_metrics -lrte_cmdline -lrte_pci -lrte_ethdev -lrte_meter -lrte_net -lrte_mbuf -lrte_mempool -lrte_rcu -lrte_ring -lrte_eal -lrte_telemetry -lrte_kvargs  
ln -sf helloworld-shared build/helloworld
[root@bogon helloworld]#

大功告成

撒花

完结