0

enter image description here

enter image description here

mlx5dv_create_flow_action_packet_reformat is a function in <infiniband/mlx5dv.h>.

error shows:undefined reference to `mlx5dv_create_flow_action_packet_reformat'.

Why can't I link the mlx5dv_create_flow_action_packet_reformat function.

Does Which mean that I need to download some dependency packages?

—————————————————————————————————————————— My 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 for 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
  • Please update with DPDK version Linux version and Distro in use. The simple explanation of the error, it is not able to find mlx5 library in the default path. I assume you are building DPDK natively (same machine build and run), then point LD_LIBRARY_PATH to location of `libverb*.so`. – Vipin Varghese Jul 14 '22 at 11:27
  • Checking your screenshot, it is not DPDK Build issue, but application using some Makefile to compile. Please share your `Makefile` to evaluate what is wrong. – Vipin Varghese Jul 14 '22 at 11:29
  • Thank you very much for your help. I have shared my Makefile above. In addtion, my project is a rpc project based on the top of DPDK(https://github.com/epfl-dcsl/r2p2). What I do is to configure and make the r2p2/dpdk-apps. – xuxing chen Jul 14 '22 at 11:43
  • Please update the DPDK version in use, so I can recommend the solution with `pkg-config` or manual – Vipin Varghese Jul 14 '22 at 15:02
  • The version of DPDK I use is 18.11. – xuxing chen Jul 15 '22 at 01:18
  • I have updated in comment where one can find the build log, please accept and upvote to close the ticket. If you need specific github project makefile change better open a ticket to the github repo team to help or share the github related question as separate question. – Vipin Varghese Jul 16 '22 at 18:13
  • as updated in comments after firing `make -n`, check the build folder of the application, there will be log file which highlights the complete cflags and ldflags used to built the application. Assuming MLX5 issue is resolved in the DPDK sample app, You can use the cflags and ldflags from there to mimic your custom application – Vipin Varghese Jul 16 '22 at 18:15

1 Answers1

1

The issue with application r2p2-echo Makefile flags, as it only include DPDK headers via -I$(RTE_SDK)/x86_64-native-linuxapp-gcc/include. Based on the logs DPDK is been built Mellanox PMD drivers which have an inherent dependency on libverbs to provide the definition for mlx5_glue_*.

Following are the ways to fix the issue

  1. if the application does not use Mellanox PMD, rebuild DPDK (< 19.11 LTS) with CONFIG_RTE_LIBRTE_MLX5_PMD=n in rte_config. Then rebuild the application.
  2. If the application does use Mellanox PMD, the CFLAGS and LDFLAGS needs modifications to accommodate the path and definition for libverbs.
  3. If the DPDK is 19.11 LTS or greater, using pkg-config one can fetch the appropriate CFLAGS and LDFLAGS.

Solution with pkg-config:

CFLAGS update:

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

and

for LDFLAGS

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

Solution for DPDK version less than 19.11 LTS:

  • execute make static -n or make -n for example/l2fwd.
  • This will generate a log for the compiler flags used for application build with DPDK libraries and dependencies.
  • Pull the necessary fields for cflags and ldflags and update the makefile.

[EDIT-1] makefile modification

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))

Note: there are errors which are associated to DPDK and Linux header versions which needs updating too for the project .

Vipin Varghese
  • 4,540
  • 2
  • 9
  • 25
  • I have tried the solution2 for DPDK vesion less than 19.11. But I really don't know which fields in the log is necessary for cflags and ldflags. I have shown my log above. I am very appraciate for your help. Thanks a lot! – xuxing chen Jul 15 '22 at 06:39
  • log file is created in build folder, which has the binary the compiler flags used for building the application – Vipin Varghese Jul 15 '22 at 10:22
  • I am using DPDK v20.05 now. So I tried the solution1 for DPDK > 19.11. I have updated the CFLAGS. However, it reports a error: `fatal error: rte_config.h: No such file or directory`. This may be due to I replace `-I$(RTE_SDK)/x86_64-native-linuxapp-gcc/include` with `$(pkg-config --cflags --static libdpdk)`. So how should I do to solve the problem? – xuxing chen Jul 17 '22 at 08:19
  • `$(pkg-config --cflags --static libdpdk)` will only return CFLAGS fileds, while `$(pkg-config --libs --static libdpdk)` return ldflags fields. Share the project link, let me take a look into the same. – Vipin Varghese Jul 18 '22 at 02:46
  • The project link: https://github.com/epfl-dcsl/r2p2/tree/master/dpdk-apps. The project is a RPC UDP-based transport protocol on the top of DPDK. Its Makefile is the same as what I showed above. – xuxing chen Jul 18 '22 at 04:44
  • As explained in the answers, I have modified the make file. Accept and upvote the answer to close the question if it has helped you. – Vipin Varghese Jul 18 '22 at 16:44