I am using dpdk-stable-19.11.3
, and the NIC is Mellaonx Connect5-X. The project’s main
function is written in C++, but all other functions it calls are written in C. I use cmake to manage my project. I packed all C code to a static library. Without dpdk, it’s fine. After adding dpdk, the CMakeLists.txt
seems missing some libs. It compiled successfully. But when running the executable file, it returns “open file error”. Then I added libs rte_pmd_mlx5
and ibverbs
. The errors occur when running command make
.
➜ build git:(master) ✗ make
-- Configuring done
-- Generating done
-- Build files have been written to: /home/hewen/demo/build
[ 83%] Built target mylib
[ 91%] Linking CXX executable demo
/home/hewen/dpdk-stable-19.11.3/x86_64-native-linuxapp-gcc/lib/librte_pmd_mlx5.a(mlx5_glue.o): In function `mlx5_glue_dv_open_device':
/home/hewen/dpdk-stable-19.11.3/drivers/net/mlx5/mlx5_glue.c:830: undefined reference to `mlx5dv_open_device'
/home/hewen/dpdk-stable-19.11.3/x86_64-native-linuxapp-gcc/lib/librte_pmd_mlx5.a(mlx5_glue.o): In function `mlx5_glue_devx_port_query':
/home/hewen/dpdk-stable-19.11.3/drivers/net/mlx5/mlx5_glue.c:1030: undefined reference to `mlx5dv_query_devx_port'
/home/hewen/dpdk-stable-19.11.3/x86_64-native-linuxapp-gcc/lib/librte_pmd_mlx5.a(mlx5_glue.o): In function `mlx5_glue_devx_qp_query':
/home/hewen/dpdk-stable-19.11.3/drivers/net/mlx5/mlx5_glue.c:1012: undefined reference to `mlx5dv_devx_qp_query'
/home/hewen/dpdk-stable-19.11.3/x86_64-native-linuxapp-gcc/lib/librte_pmd_mlx5.a(mlx5_glue.o): In function `mlx5_glue_devx_umem_dereg':
/home/hewen/dpdk-stable-19.11.3/drivers/net/mlx5/mlx5_glue.c:999: undefined reference to `mlx5dv_devx_umem_dereg'
/home/hewen/dpdk-stable-19.11.3/x86_64-native-linuxapp-gcc/lib/librte_pmd_mlx5.a(mlx5_glue.o): In function `mlx5_glue_devx_umem_reg':
/home/hewen/dpdk-stable-19.11.3/drivers/net/mlx5/mlx5_glue.c:984: undefined reference to `mlx5dv_devx_umem_reg'
/home/hewen/dpdk-stable-19.11.3/x86_64-native-linuxapp-gcc/lib/librte_pmd_mlx5.a(mlx5_glue.o): In function `mlx5_glue_devx_get_async_cmd_comp':
/home/hewen/dpdk-stable-19.11.3/drivers/net/mlx5/mlx5_glue.c:969: undefined reference to `mlx5dv_devx_get_async_cmd_comp'
/home/hewen/dpdk-stable-19.11.3/x86_64-native-linuxapp-gcc/lib/librte_pmd_mlx5.a(mlx5_glue.o): In function `mlx5_glue_devx_obj_query_async':
/home/hewen/dpdk-stable-19.11.3/drivers/net/mlx5/mlx5_glue.c:950: undefined reference to `mlx5dv_devx_obj_query_async'
/home/hewen/dpdk-stable-19.11.3/x86_64-native-linuxapp-gcc/lib/librte_pmd_mlx5.a(mlx5_glue.o): In function `mlx5_glue_devx_destroy_cmd_comp':
/home/hewen/dpdk-stable-19.11.3/drivers/net/mlx5/mlx5_glue.c:937: undefined reference to `mlx5dv_devx_destroy_cmd_comp'
/home/hewen/dpdk-stable-19.11.3/x86_64-native-linuxapp-gcc/lib/librte_pmd_mlx5.a(mlx5_glue.o): In function `mlx5_glue_devx_create_cmd_comp':
/home/hewen/dpdk-stable-19.11.3/drivers/net/mlx5/mlx5_glue.c:925: undefined reference to `mlx5dv_devx_create_cmd_comp'
/home/hewen/dpdk-stable-19.11.3/x86_64-native-linuxapp-gcc/lib/librte_pmd_mlx5.a(mlx5_glue.o): In function `mlx5_glue_devx_general_cmd':
/home/hewen/dpdk-stable-19.11.3/drivers/net/mlx5/mlx5_glue.c:910: undefined reference to `mlx5dv_devx_general_cmd'
/home/hewen/dpdk-stable-19.11.3/x86_64-native-linuxapp-gcc/lib/librte_pmd_mlx5.a(mlx5_glue.o): In function `mlx5_glue_devx_obj_modify':
/home/hewen/dpdk-stable-19.11.3/drivers/net/mlx5/mlx5_glue.c:893: undefined reference to `mlx5dv_devx_obj_modify'
/home/hewen/dpdk-stable-19.11.3/x86_64-native-linuxapp-gcc/lib/librte_pmd_mlx5.a(mlx5_glue.o): In function `mlx5_glue_devx_obj_query':
/home/hewen/dpdk-stable-19.11.3/drivers/net/mlx5/mlx5_glue.c:876: undefined reference to `mlx5dv_devx_obj_query'
/home/hewen/dpdk-stable-19.11.3/x86_64-native-linuxapp-gcc/lib/librte_pmd_mlx5.a(mlx5_glue.o): In function `mlx5_glue_devx_obj_destroy':
/home/hewen/dpdk-stable-19.11.3/drivers/net/mlx5/mlx5_glue.c:863: undefined reference to `mlx5dv_devx_obj_destroy'
/home/hewen/dpdk-stable-19.11.3/x86_64-native-linuxapp-gcc/lib/librte_pmd_mlx5.a(mlx5_glue.o): In function `mlx5_glue_devx_obj_create':
/home/hewen/dpdk-stable-19.11.3/drivers/net/mlx5/mlx5_glue.c:847: undefined reference to `mlx5dv_devx_obj_create'
/home/hewen/dpdk-stable-19.11.3/x86_64-native-linuxapp-gcc/lib/librte_pmd_mlx5.a(mlx5_glue.o): In function `mlx5_glue_dv_destroy_flow_matcher':
/home/hewen/dpdk-stable-19.11.3/drivers/net/mlx5/mlx5_glue.c:815: undefined reference to `mlx5dv_dr_matcher_destroy'
/home/hewen/dpdk-stable-19.11.3/x86_64-native-linuxapp-gcc/lib/librte_pmd_mlx5.a(mlx5_glue.o): In function `mlx5_glue_dv_destroy_flow':
/home/hewen/dpdk-stable-19.11.3/drivers/net/mlx5/mlx5_glue.c:804: undefined reference to `mlx5dv_dr_rule_destroy'
...
/home/hewen/dpdk-stable-19.11.3/x86_64-native-linuxapp-gcc/lib/librte_pmd_mlx5.a(mlx5_glue.o): In function `mlx5_glue_dr_create_flow_action_push_vlan':
/home/hewen/dpdk-stable-19.11.3/drivers/net/mlx5/mlx5_glue.c:426: undefined reference to `mlx5dv_dr_action_create_push_vlan'
/home/hewen/dpdk-stable-19.11.3/x86_64-native-linuxapp-gcc/lib/librte_pmd_mlx5.a(mlx5_glue.o): In function `mlx5_glue_dr_create_flow_action_drop':
/home/hewen/dpdk-stable-19.11.3/drivers/net/mlx5/mlx5_glue.c:414: undefined reference to `mlx5dv_dr_action_create_drop'
/home/hewen/dpdk-stable-19.11.3/x86_64-native-linuxapp-gcc/lib/librte_pmd_mlx5.a(mlx5_glue.o): In function `mlx5_glue_dr_create_flow_action_dest_port':
/home/hewen/dpdk-stable-19.11.3/drivers/net/mlx5/mlx5_glue.c:397: undefined reference to `mlx5dv_dr_action_create_dest_ib_port'
/home/hewen/dpdk-stable-19.11.3/x86_64-native-linuxapp-gcc/lib/librte_pmd_mlx5.a(mlx5_glue.o): In function `mlx5_glue_dr_create_flow_action_dest_flow_tbl':
/home/hewen/dpdk-stable-19.11.3/drivers/net/mlx5/mlx5_glue.c:385: undefined reference to `mlx5dv_dr_action_create_dest_table'
/home/hewen/dpdk-stable-19.11.3/x86_64-native-linuxapp-gcc/lib/librte_pmd_mlx5.a(mlx5_glue.o): In function `mlx5_glue_destroy_flow_action':
/home/hewen/dpdk-stable-19.11.3/drivers/net/mlx5/mlx5_glue.c:190: undefined reference to `mlx5dv_dr_action_destroy'
collect2: error: ld returned 1 exit status
CMakeFiles/demo.dir/build.make:95: recipe for target 'demo' failed
make[2]: *** [demo] Error 1
CMakeFiles/Makefile2:104: recipe for target 'CMakeFiles/demo.dir/all' failed
Is there any libs I missed? This is my CMakeLists.txt
.
cmake_minimum_required(VERSION 3.10)
project(myPJ LANGUAGES C CXX)
find_package(Threads REQUIRED)
set(CMAKE_C_STANDARD 11)
set(CMAKE_CXX_FLAGS "-msse4.2")
option(DEBUG "add complie options for gdb" ON)
set(RTE_SDK /home/hewen/dpdk-stable-19.11.3)
set(RTE_TARGET x86_64-native-linuxapp-gcc)
include_directories(${RTE_SDK}/${RTE_TARGET}/include)
link_directories(${RTE_SDK}/${RTE_TARGET}/lib)
include_directories(./tools)
link_directories("./tools/")
add_definitions(-pthread)
if(DEBUG)
add_compile_options(-g -O0)
endif()
add_definitions(-DBUCKET_CLEANER)
add_definitions(-DCOLLECT_STATS -DTABLE_COLLECT_STATS -DLOG_COLLECT_STATS)
add_definitions(-DVERBOSE)
add_library(mylib STATIC a.c b.c c.c d.c)
add_executable(demo main.cpp)
target_link_libraries(demo PRIVATE mylib)
target_link_libraries(demo PRIVATE libxxhash.so)
target_link_libraries(demo PRIVATE Threads::Threads)
target_link_libraries(demo PRIVATE
-Wl,--whole-archive
rte_ethdev
rte_eal
rte_mempool
rte_pmd_mlx5
ibverbs
rte_pmd_e1000
rte_pmd_i40e
rte_pmd_ixgbe
rte_pmd_virtio
rte_pmd_vmxnet3_uio
rte_hash
rte_kvargs
rte_bus_pci
rte_pci
rte_bus_vdev
rte_mbuf
rte_ring
rte_net
pthread
dl
-Wl,--no-whole-archive
numa
rt
pcap
m
)