对 DPDK mlx5 中“mlx5dv_create_flow_action_packet_reformat”的未定义引用

undefined reference to `mlx5dv_create_flow_action_packet_reformat' in DPDK mlx5

提问人:xuxing chen 提问时间:7/14/2022 最后编辑:xuxing chen 更新时间:7/19/2022 访问量:314

问:

enter image description here

enter image description here

mlx5dv_create_flow_action_packet_reformat是 <infiniband/mlx5dv.h> 中的一个函数。

错误显示:未定义对“mlx5dv_create_flow_action_packet_reformat”的引用。

为什么我无法链接mlx5dv_create_flow_action_packet_reformat功能。

这是否意味着我需要下载一些依赖包?

—————————————————————————————————————————— 我的 Makefile:

ROOTDIR=$(shell git rev-parse --show-toplevel)
RTE_SDK=/home/cxx/dpdk-18.11
R2P2LIB_DIR=$(ROOTDIR)/r2p2
RAFT_DIR=$(shell git rev-parse --show-toplevel)/../raft

include $(ROOTDIR)/netstack/dp/dir.mk
include $(ROOTDIR)/netstack/net/dir.mk
include $(R2P2LIB_DIR)/dir.mk


CC=gcc
CFLAGS += -g -O3 -I$(ROOTDIR)/netstack/inc -I$(R2P2LIB_DIR)/inc -I$(RTE_SDK)/x86_64-native-linuxapp-gcc/include -I$(RAFT_DIR)/include -DNO_BATCH #-DACCELERATED #-DRAFT_STATS

ifeq ($(WITH_RAFT), 1)
    CFLAGS += -DWITH_RAFT
endif

ifeq ($(LB_REPLIES), 1)
    CFLAGS += -DLB_REPLIES
endif

ifeq ($(SKIP_NO_SE), 1)
    CFLAGS += -DSKIP_NO_SE
endif

ifeq ($(ACCELERATED), 1)
    CFLAGS += -DACCELERATED
endif

ifeq ($(SWITCH_AGG), 1)
    CFLAGS += -DSWITCH_AGG
endif

ifeq ($(SMART_LB), 1)
    CFLAGS += -DSMART_LB
endif

ifeq ($(VIEW_CHANGE_EXP), 1)
    CFLAGS += -DVIEW_CHANGE_EXP
endif

ifdef PACKET_LOSS
    CFLAGS += -DPACKET_LOSS=$(PACKET_LOSS)
endif

WERROR_FLAGS := -W -Wall -Wstrict-prototypes -Wmissing-prototypes
WERROR_FLAGS += -Wmissing-declarations -Wold-style-definition -Wpointer-arith
WERROR_FLAGS += -Wcast-align -Wnested-externs -Wcast-qual
WERROR_FLAGS += -Wformat-nonliteral -Wformat-security
WERROR_FLAGS += -Wundef -Wwrite-strings

CFLAGS += $(WERROR_FLAGS) -mavx2
LDFLAGS= -Wl,--whole-archive -Wl,-ldpdk -Wl,--no-whole-archive -lrt -lpthread -lm -ldl -L$(RTE_SDK)/x86_64-native-linuxapp-gcc/lib -lconfig -lnuma -lgcov --coverage -lpcap

SRCS_C := $(addprefix $(ROOTDIR)/netstack/dp/, $(DP_SRC)) $(addprefix $(ROOTDIR)/netstack/net/, $(NET_SRC)) $(addprefix $(R2P2LIB_DIR)/, $(R2P2_SRC_C))
OBJS_C := $(patsubst %.c, %.o, $(SRCS_C))

ifeq ($(WITH_RAFT), 1)
    OBJS_C += $(RAFT_DIR)/libraft.a
endif

all:
    make r2p2-echo
    make r2p2-echo-fdir
    make synthetic-time
    make synthetic-time-fdir
    make r2p2-router
    make udp-echo
    make udp-synthetic

debug: cleanstate debug.o $(OBJS_C)
    $(CC) -o $@ debug.o $(OBJS_C) $(LDFLAGS)

r2p2-echo: cleanstate r2p2-echo.o $(OBJS_C)
    $(CC) -o $@ r2p2-echo.o $(OBJS_C) $(LDFLAGS)

r2p2-echo-fdir: CFLAGS += -DFDIR
r2p2-echo-fdir: cleanstate r2p2-echo.o $(OBJS_C)
    $(CC) -o $@ r2p2-echo.o $(OBJS_C) $(LDFLAGS)

stss: cleanstate r2p2-stss.o $(OBJS_C)
    $(CC) -o $@ r2p2-stss.o $(OBJS_C) $(LDFLAGS)

synthetic-size: cleanstate r2p2-synthetic-size.o $(OBJS_C)
    $(CC) -o $@ r2p2-synthetic-size.o $(OBJS_C) $(LDFLAGS)

synthetic-time: cleanstate r2p2-synthetic-time.o $(OBJS_C)
    $(CC) -o $@ r2p2-synthetic-time.o $(OBJS_C) $(LDFLAGS)

synthetic-time-fdir: CFLAGS += -DFDIR
synthetic-time-fdir: cleanstate r2p2-synthetic-time.o $(OBJS_C)
    $(CC) -o $@ r2p2-synthetic-time.o $(OBJS_C) $(LDFLAGS)

r2p2-router: CFLAGS += -DROUTER
r2p2-router: cleanstate r2p2-router.o $(OBJS_C)
    $(CC) -o $@ r2p2-router.o $(OBJS_C) $(LDFLAGS)

udp-echo: cleanstate udp-echo.o $(OBJS_C)
    $(CC) -o $@ udp-echo.o $(OBJS_C) $(LDFLAGS)

udp-synthetic: cleanstate udp-synthetic.o $(OBJS_C)
    $(CC) -o $@ udp-synthetic.o $(OBJS_C) $(LDFLAGS)

cleanstate:
    make -C $(R2P2LIB_DIR) clean
    make clean
    rm -f $(ROOTDIR)/netstack/net/*.o
    rm -f $(ROOTDIR)/netstack/dp/*.o

clean:
    rm -f *.o

distclean:
    make clean
    rm -f synthetic-time-fdir synthetic-time r2p2-router udp-echo

make -n 用于 l2fwd show:

[cxx@tcsys-node1 l2fwd]$ make -n
mkdir -p /home/cxx/dpdk-18.11/examples/l2fwd/build
make -C /home/cxx/dpdk-18.11/examples/l2fwd/build -f /home/cxx/dpdk-18.11/examples/l2fwd/Makefile \
        S=/home/cxx/dpdk-18.11/examples/l2fwd O=/home/cxx/dpdk-18.11/examples/l2fwd/build SRCDIR=/home/cxx/dpdk-18.11/examples/l2fwd
[ -d ./ ] || mkdir -p ./
[ -d ./ ] || mkdir -p ./
set -e; echo "  LD l2fwd"; gcc -o l2fwd -m64 -pthread  -march=native -DRTE_MACHINE_CPUFLAG_SSE -DRTE_MACHINE_CPUFLAG_SSE2 -DRTE_MACHINE_CPUFLAG_SSE3 -DRTE_MACHINE_CPUFLAG_SSSE3 -DRTE_MACHINE_CPUFLAG_SSE4_1 -DRTE_MACHINE_CPUFLAG_SSE4_2 -DRTE_MACHINE_CPUFLAG_AES -DRTE_MACHINE_CPUFLAG_PCLMULQDQ -DRTE_MACHINE_CPUFLAG_AVX -DRTE_MACHINE_CPUFLAG_RDRAND -DRTE_MACHINE_CPUFLAG_FSGSBASE -DRTE_MACHINE_CPUFLAG_F16C -DRTE_MACHINE_CPUFLAG_AVX2  -I/home/cxx/dpdk-18.11/examples/l2fwd/build/include -I/home/cxx/dpdk-18.11/x86_64-native-linuxapp-gcc/include -include /home/cxx/dpdk-18.11/x86_64-native-linuxapp-gcc/include/rte_config.h -D_GNU_SOURCE -O3 -W -Wall -Wstrict-prototypes -Wmissing-prototypes -Wmissing-declarations -Wold-style-definition -Wpointer-arith -Wcast-align -Wnested-externs -Wcast-qual -Wformat-nonliteral -Wformat-security -Wundef -Wwrite-strings -Wdeprecated -Wno-address-of-packed-member  main.o -L/home/cxx/dpdk-18.11/x86_64-native-linuxapp-gcc/lib -Wl,-lrte_flow_classify -Wl,--whole-archive -Wl,-lrte_pipeline -Wl,--no-whole-archive -Wl,--whole-archive -Wl,-lrte_table -Wl,--no-whole-archive -Wl,--whole-archive -Wl,-lrte_port -Wl,--no-whole-archive -Wl,-lrte_pdump -Wl,-lrte_distributor -Wl,-lrte_ip_frag -Wl,-lrte_meter -Wl,-lrte_lpm -Wl,--whole-archive -Wl,-lrte_acl -Wl,--no-whole-archive -Wl,-lrte_jobstats -Wl,-lrte_metrics -Wl,-lrte_bitratestats -Wl,-lrte_latencystats -Wl,-lrte_power -Wl,-lrte_efd -Wl,-lrte_bpf -Wl,--whole-archive -Wl,-lrte_cfgfile -Wl,-lrte_gro -Wl,-lrte_gso -Wl,-lrte_hash -Wl,-lrte_member -Wl,-lrte_vhost -Wl,-lrte_kvargs -Wl,-lrte_mbuf -Wl,-lrte_net -Wl,-lrte_ethdev -Wl,-lrte_bbdev -Wl,-lrte_cryptodev -Wl,-lrte_security -Wl,-lrte_compressdev -Wl,-lrte_eventdev -Wl,-lrte_rawdev -Wl,-lrte_timer -Wl,-lrte_mempool -Wl,-lrte_mempool_ring -Wl,-lrte_ring -Wl,-lrte_pci -Wl,-lrte_eal -Wl,-lrte_cmdline -Wl,-lrte_reorder -Wl,-lrte_sched -Wl,-lrte_kni -Wl,-lrte_common_cpt -Wl,-lrte_common_octeontx -Wl,-lrte_common_dpaax -Wl,-lrte_bus_pci -Wl,-lrte_bus_vdev -Wl,-lrte_bus_dpaa -Wl,-lrte_bus_fslmc -Wl,-lrte_mempool_bucket -Wl,-lrte_mempool_stack -Wl,-lrte_mempool_dpaa -Wl,-lrte_mempool_dpaa2 -Wl,-lrte_pmd_af_packet -Wl,-lrte_pmd_ark -Wl,-lrte_pmd_atlantic -Wl,-lrte_pmd_avf -Wl,-lrte_pmd_avp -Wl,-lrte_pmd_axgbe -Wl,-lrte_pmd_bnxt -Wl,-lrte_pmd_bond -Wl,-lrte_pmd_cxgbe -Wl,-lrte_pmd_dpaa -Wl,-lrte_pmd_dpaa2 -Wl,-lrte_pmd_e1000 -Wl,-lrte_pmd_ena -Wl,-lrte_pmd_enetc -Wl,-lrte_pmd_enic -Wl,-lrte_pmd_fm10k -Wl,-lrte_pmd_failsafe -Wl,-lrte_pmd_i40e -Wl,-lrte_pmd_ixgbe -Wl,-lrte_pmd_kni -Wl,-lrte_pmd_lio -Wl,-lrte_pmd_mlx5 -Wl,-libverbs -Wl,-lmlx5 -Wl,-lmnl -Wl,-lrte_pmd_nfp -Wl,-lrte_pmd_null -Wl,-lrte_pmd_qede -Wl,-lrte_pmd_ring -Wl,-lrte_pmd_softnic -Wl,-lrte_pmd_sfc_efx -Wl,-lrte_pmd_tap -Wl,-lrte_pmd_thunderx_nicvf -Wl,-lrte_pmd_vdev_netvsc -Wl,-lrte_pmd_virtio -Wl,-lrte_pmd_vhost -Wl,-lrte_pmd_ifc -Wl,-lrte_pmd_vmxnet3_uio -Wl,-lrte_bus_vmbus -Wl,-lrte_pmd_netvsc -Wl,-lrte_pmd_bbdev_null -Wl,-lrte_pmd_null_crypto -Wl,-lrte_pmd_octeontx_crypto -Wl,-lrte_pmd_crypto_scheduler -Wl,-lrte_pmd_dpaa2_sec -Wl,-lrte_pmd_dpaa_sec -Wl,-lrte_pmd_caam_jr -Wl,-lrte_pmd_virtio_crypto -Wl,-lrte_pmd_octeontx_zip -Wl,-lrte_pmd_qat -Wl,-lrte_pmd_skeleton_event -Wl,-lrte_pmd_sw_event -Wl,-lrte_pmd_dsw_event -Wl,-lrte_pmd_octeontx_ssovf -Wl,-lrte_pmd_dpaa_event -Wl,-lrte_pmd_dpaa2_event -Wl,-lrte_mempool_octeontx -Wl,-lrte_pmd_octeontx -Wl,-lrte_pmd_opdl_event -Wl,-lrte_pmd_skeleton_rawdev -Wl,-lrte_pmd_dpaa2_cmdif -Wl,-lrte_pmd_dpaa2_qdma -Wl,-lrte_bus_ifpga -Wl,-lrte_pmd_ifpga_rawdev -Wl,--no-whole-archive -Wl,-lrt -Wl,-lm -Wl,-lnuma -Wl,-ldl -Wl,-export-dynamic -Wl,-export-dynamic -L/home/cxx/dpdk-18.11/examples/l2fwd/build/lib -L/home/cxx/dpdk-18.11/x86_64-native-linuxapp-gcc/lib -Wl,--as-needed -Wl,-Map=l2fwd.map -Wl,--cref && echo "cmd_l2fwd = gcc -o l2fwd -m64 -pthread  -march=native -DRTE_MACHINE_CPUFLAG_SSE -DRTE_MACHINE_CPUFLAG_SSE2 -DRTE_MACHINE_CPUFLAG_SSE3 -DRTE_MACHINE_CPUFLAG_SSSE3 -DRTE_MACHINE_CPUFLAG_SSE4_1 -DRTE_MACHINE_CPUFLAG_SSE4_2 -DRTE_MACHINE_CPUFLAG_AES -DRTE_MACHINE_CPUFLAG_PCLMULQDQ -DRTE_MACHINE_CPUFLAG_AVX -DRTE_MACHINE_CPUFLAG_RDRAND -DRTE_MACHINE_CPUFLAG_FSGSBASE -DRTE_MACHINE_CPUFLAG_F16C -DRTE_MACHINE_CPUFLAG_AVX2  -I/home/cxx/dpdk-18.11/examples/l2fwd/build/include -I/home/cxx/dpdk-18.11/x86_64-native-linuxapp-gcc/include -include /home/cxx/dpdk-18.11/x86_64-native-linuxapp-gcc/include/rte_config.h -D_GNU_SOURCE -O3 -W -Wall -Wstrict-prototypes -Wmissing-prototypes -Wmissing-declarations -Wold-style-definition -Wpointer-arith -Wcast-align -Wnested-externs -Wcast-qual -Wformat-nonliteral -Wformat-security -Wundef -Wwrite-strings -Wdeprecated -Wno-address-of-packed-member  main.o -L/home/cxx/dpdk-18.11/x86_64-native-linuxapp-gcc/lib -Wl,-lrte_flow_classify -Wl,--whole-archive -Wl,-lrte_pipeline -Wl,--no-whole-archive -Wl,--whole-archive -Wl,-lrte_table -Wl,--no-whole-archive -Wl,--whole-archive -Wl,-lrte_port -Wl,--no-whole-archive -Wl,-lrte_pdump -Wl,-lrte_distributor -Wl,-lrte_ip_frag -Wl,-lrte_meter -Wl,-lrte_lpm -Wl,--whole-archive -Wl,-lrte_acl -Wl,--no-whole-archive -Wl,-lrte_jobstats -Wl,-lrte_metrics -Wl,-lrte_bitratestats -Wl,-lrte_latencystats -Wl,-lrte_power -Wl,-lrte_efd -Wl,-lrte_bpf -Wl,--whole-archive -Wl,-lrte_cfgfile -Wl,-lrte_gro -Wl,-lrte_gso -Wl,-lrte_hash -Wl,-lrte_member -Wl,-lrte_vhost -Wl,-lrte_kvargs -Wl,-lrte_mbuf -Wl,-lrte_net -Wl,-lrte_ethdev -Wl,-lrte_bbdev -Wl,-lrte_cryptodev -Wl,-lrte_security -Wl,-lrte_compressdev -Wl,-lrte_eventdev -Wl,-lrte_rawdev -Wl,-lrte_timer -Wl,-lrte_mempool -Wl,-lrte_mempool_ring -Wl,-lrte_ring -Wl,-lrte_pci -Wl,-lrte_eal -Wl,-lrte_cmdline -Wl,-lrte_reorder -Wl,-lrte_sched -Wl,-lrte_kni -Wl,-lrte_common_cpt -Wl,-lrte_common_octeontx -Wl,-lrte_common_dpaax -Wl,-lrte_bus_pci -Wl,-lrte_bus_vdev -Wl,-lrte_bus_dpaa -Wl,-lrte_bus_fslmc -Wl,-lrte_mempool_bucket -Wl,-lrte_mempool_stack -Wl,-lrte_mempool_dpaa -Wl,-lrte_mempool_dpaa2 -Wl,-lrte_pmd_af_packet -Wl,-lrte_pmd_ark -Wl,-lrte_pmd_atlantic -Wl,-lrte_pmd_avf -Wl,-lrte_pmd_avp -Wl,-lrte_pmd_axgbe -Wl,-lrte_pmd_bnxt -Wl,-lrte_pmd_bond -Wl,-lrte_pmd_cxgbe -Wl,-lrte_pmd_dpaa -Wl,-lrte_pmd_dpaa2 -Wl,-lrte_pmd_e1000 -Wl,-lrte_pmd_ena -Wl,-lrte_pmd_enetc -Wl,-lrte_pmd_enic -Wl,-lrte_pmd_fm10k -Wl,-lrte_pmd_failsafe -Wl,-lrte_pmd_i40e -Wl,-lrte_pmd_ixgbe -Wl,-lrte_pmd_kni -Wl,-lrte_pmd_lio -Wl,-lrte_pmd_mlx5 -Wl,-libverbs -Wl,-lmlx5 -Wl,-lmnl -Wl,-lrte_pmd_nfp -Wl,-lrte_pmd_null -Wl,-lrte_pmd_qede -Wl,-lrte_pmd_ring -Wl,-lrte_pmd_softnic -Wl,-lrte_pmd_sfc_efx -Wl,-lrte_pmd_tap -Wl,-lrte_pmd_thunderx_nicvf -Wl,-lrte_pmd_vdev_netvsc -Wl,-lrte_pmd_virtio -Wl,-lrte_pmd_vhost -Wl,-lrte_pmd_ifc -Wl,-lrte_pmd_vmxnet3_uio -Wl,-lrte_bus_vmbus -Wl,-lrte_pmd_netvsc -Wl,-lrte_pmd_bbdev_null -Wl,-lrte_pmd_null_crypto -Wl,-lrte_pmd_octeontx_crypto -Wl,-lrte_pmd_crypto_scheduler -Wl,-lrte_pmd_dpaa2_sec -Wl,-lrte_pmd_dpaa_sec -Wl,-lrte_pmd_caam_jr -Wl,-lrte_pmd_virtio_crypto -Wl,-lrte_pmd_octeontx_zip -Wl,-lrte_pmd_qat -Wl,-lrte_pmd_skeleton_event -Wl,-lrte_pmd_sw_event -Wl,-lrte_pmd_dsw_event -Wl,-lrte_pmd_octeontx_ssovf -Wl,-lrte_pmd_dpaa_event -Wl,-lrte_pmd_dpaa2_event -Wl,-lrte_mempool_octeontx -Wl,-lrte_pmd_octeontx -Wl,-lrte_pmd_opdl_event -Wl,-lrte_pmd_skeleton_rawdev -Wl,-lrte_pmd_dpaa2_cmdif -Wl,-lrte_pmd_dpaa2_qdma -Wl,-lrte_bus_ifpga -Wl,-lrte_pmd_ifpga_rawdev -Wl,--no-whole-archive -Wl,-lrt -Wl,-lm -Wl,-lnuma -Wl,-ldl -Wl,-export-dynamic -Wl,-export-dynamic -L/home/cxx/dpdk-18.11/examples/l2fwd/build/lib -L/home/cxx/dpdk-18.11/x86_64-native-linuxapp-gcc/lib -Wl,--as-needed -Wl,-Map=l2fwd.map -Wl,--cref " > ./.l2fwd.cmd
touch _postbuild
echo "  INSTALL-APP l2fwd"
[ -d /home/cxx/dpdk-18.11/examples/l2fwd/build/app ] || mkdir -p /home/cxx/dpdk-18.11/examples/l2fwd/build/app
cp -f l2fwd /home/cxx/dpdk-18.11/examples/l2fwd/build/app
echo "  INSTALL-MAP l2fwd.map"
[ -d /home/cxx/dpdk-18.11/examples/l2fwd/build/app ] || mkdir -p /home/cxx/dpdk-18.11/examples/l2fwd/build/app
cp -f l2fwd.map /home/cxx/dpdk-18.11/examples/l2fwd/build/app
touch _install
true
touch _postinstall
超链接 未定义引用 DPDK mellanox

评论

0赞 Vipin Varghese 7/14/2022
请使用 DPDK 版本、Linux 版本和正在使用的发行版进行更新。错误的简单解释,就是在默认路径下找不到mlx5库。我假设您正在本地构建 DPDK(相同的机器构建和运行),然后LD_LIBRARY_PATH指向 的位置。libverb*.so
0赞 Vipin Varghese 7/14/2022
检查您的屏幕截图,这不是 DPDK 构建问题,而是使用某些 Makefile 进行编译的应用程序。请分享您的以评估问题所在。Makefile
0赞 xuxing chen 7/14/2022
非常感谢您的帮助。我已经在上面分享了我的 Makefile。此外,我的项目是一个基于 DPDK(github.com/epfl-dcsl/r2p2) 顶部的 rpc 项目。我所做的是配置和制作 r2p2/dpdk-apps。
0赞 Vipin Varghese 7/14/2022
请更新正在使用的 DPDK 版本,以便我可以推荐使用或手动的解决方案pkg-config
0赞 xuxing chen 7/15/2022
我使用的 DPDK 版本是 18.11。

答:

1赞 Vipin Varghese 7/15/2022 #1

应用程序 Makefile 标志的问题,因为它仅包含通过 的 DPDK 标头。基于日志 .r2p2-echo-I$(RTE_SDK)/x86_64-native-linuxapp-gcc/includeDPDK is been built Mellanox PMD drivers which have an inherent dependency on libverbs to provide the definition for mlx5_glue_*

以下是解决问题的方法

  1. 如果应用程序不使用 Mellanox PMD,请使用 重建 DPDK (< 19.11 LTS)。然后重新生成应用程序。CONFIG_RTE_LIBRTE_MLX5_PMD=nrte_config
  2. 如果应用程序确实使用 Mellanox PMD,则需要修改 CFLAGS 和 LDFLAGS 以适应 libverb 的路径和定义。
  3. 如果 DPDK 为 19.11 LTS 或更高,则使用 DPDK 可以获取相应的 CFLAGS 和 LDFLAGS。pkg-config

使用 pkg-config 的解决方案:

CFLAGS更新:

CFLAGS += -g -O3 -I$(ROOTDIR)/netstack/inc -I$(R2P2LIB_DIR)/inc $(pkg-config --cflags --static libdpdk) -I$(RAFT_DIR)/include -DNO_BATCH #-DACCELERATED #-DRAFT_STATS

用于 LDFLAGS

r2p2-echo: cleanstate r2p2-echo.o $(OBJS_C)
    $(CC) -o $@ r2p2-echo.o $(OBJS_C) $(LDFLAGS) $(pkg-config --static --libs libdpdk)

DPDK 版本低于 19.11 LTS 的解决方案:

  • 执行 。make static -n or make -nexample/l2fwd
  • 这将为用于使用 DPDK 库和依赖项构建应用程序的编译器标志生成日志。
  • 提取 cflags 和 ldflags 的必要字段并更新 makefile。

[EDIT-1] makefile修改

diff --git a/dpdk-apps/Makefile b/dpdk-apps/Makefile
index 3da318d..40a1e2f 100644
--- a/dpdk-apps/Makefile
+++ b/dpdk-apps/Makefile
@@ -31,7 +31,14 @@ include $(R2P2LIB_DIR)/dir.mk


 CC=gcc
-CFLAGS += -g -O3 -I$(ROOTDIR)/netstack/inc -I$(R2P2LIB_DIR)/inc -I$(RTE_SDK)/x86_64-native-linuxapp-gcc/include -I$(RAFT_DIR)/include -DNO_BATCH #-DACCELERATED #-DRAFT_STATS
+CFLAGS += -g -O3 -I$(ROOTDIR)/netstack/inc -I$(R2P2LIB_DIR)/inc -I$(RAFT_DIR)/include -DNO_BATCH #-DACCELERATED #-DRAFT_STATS
+
+DPDK_VERSION:=$(shell  pkg-config --modversion libdpdk)
+ifneq ("$(DPDK_VERSION)", "")
+       CFLAGS += ${shell pkg-config --cflags --static libdpdk}
+else
+       CFLAGS += -I$(RTE_SDK)/x86_64-native-linuxapp-gcc/include
+endif

 ifeq ($(WITH_RAFT), 1)
        CFLAGS += -DWITH_RAFT
@@ -72,7 +79,13 @@ WERROR_FLAGS += -Wformat-nonliteral -Wformat-security
 WERROR_FLAGS += -Wundef -Wwrite-strings

 CFLAGS += $(WERROR_FLAGS) -mavx2
-LDFLAGS= -Wl,--whole-archive -Wl,-ldpdk -Wl,--no-whole-archive -lrt -lpthread -lm -ldl -L$(RTE_SDK)/x86_64-native-linuxapp-gcc/lib -lconfig -lnuma -lgcov --coverage -lpcap
+
+ifneq ("$(DPDK_VERSION)", "")
+       LDFLAGS += ${shell pkg-config --libs --static libdpdk}
+else
+       LDFLAGS= -Wl,--whole-archive -Wl,-ldpdk -Wl,--no-whole-archive -lrt -lpthread -lm -ldl -L$(RTE_SDK)/x86_64-native-linuxapp-gcc/lib -lconfig -lnuma -lgcov --coverage -lpcap
+endif
+LDFLAGS += -lconfig -lgcov --coverage -lpcap

 SRCS_C := $(addprefix $(ROOTDIR)/netstack/dp/, $(DP_SRC)) $(addprefix $(ROOTDIR)/netstack/net/, $(NET_SRC)) $(addprefix $(R2P2LIB_DIR)/, $(R2P2_SRC_C))
 OBJS_C := $(patsubst %.c, %.o, $(SRCS_C))

注意:有些错误与DPDK和Linux头版本相关联,项目也需要更新。

评论

0赞 xuxing chen 7/15/2022
我已经尝试了低于 19.11 的 DPDK vesion 的解决方案 2。但是我真的不知道日志中的哪些字段是 cflags 和 ldflags 所必需的。我已经在上面显示了我的日志。我非常感谢您的帮助。多谢!
0赞 Vipin Varghese 7/15/2022
日志文件在 build 文件夹中创建,其中包含用于构建应用程序的编译器标志的二进制文件
0赞 xuxing chen 7/17/2022
我现在正在使用 DPDK v20.05。因此,我尝试了 DPDK > 19.11 的解决方案 1。我已经更新了 CFLAGS。但是,它会报告一个错误: 。这可能是由于我用 .那么我应该怎么做才能解决这个问题呢?fatal error: rte_config.h: No such file or directory-I$(RTE_SDK)/x86_64-native-linuxapp-gcc/include$(pkg-config --cflags --static libdpdk)
0赞 Vipin Varghese 7/18/2022
$(pkg-config --cflags --static libdpdk)将仅返回 CFLAGS fileds,而返回 ldflags 字段。分享项目链接,让我一起来看看。$(pkg-config --libs --static libdpdk)
0赞 xuxing chen 7/18/2022
项目链接:github.com/epfl-dcsl/r2p2/tree/master/dpdk-apps。该项目是 DPDK 之上的基于 RPC UDP 的传输协议。它的 Makefile 与我上面显示的相同。