gcc - 将外部 DPVS 应用程序(使用 Makefile)与使用 Meson 构建的 DPDK 链接
问题描述
DPVS 建议使用dpdk-stable-18.11.2使用 Makefile 进行构建。但是当前的 DPDK LTS 版本 18.11.11 支持 meson -ninja构建系统以及 Makefile 系统。
我一直在试验port to a more recent DPDK version
只支持介子忍者而不是不推荐使用的 Makefile 系统的代码。我的问题DPVS 链接问题是在链接到使用 meson-ninja 构建的 DPDK 时,我无法解决依赖问题。当我尝试链接使用 Makefiles 构建的 DPDK 18.11 时,同样的工作没有问题。我正在使用 KVM-QEMU运行带有 NIC Virtio/E1000的来宾操作系统。来宾操作系统是Ubuntu 18.04 LTS (x64)。
DPDK 库通过 dpdk.mk 由 DPVS 项目链接,当前链接选项为:
LIBS += -Wl,--no-as-needed -fvisibility=default \
-Wl,--whole-archive -lrte_pmd_vmxnet3_uio -lrte_pmd_i40e -lrte_pmd_ixgbe \
-lrte_pmd_e1000 -lrte_pmd_bnxt -lrte_pmd_ring -lrte_pmd_bond -lrte_ethdev -lrte_ip_frag \
-Wl,--whole-archive -lrte_hash -lrte_kvargs -Wl,-lrte_mbuf -lrte_eal \
-Wl,-lrte_mempool -lrte_ring -lrte_cmdline -lrte_cfgfile -lrte_kni \
-lrte_mempool_ring -lrte_timer -lrte_net -Wl,-lrte_pmd_virtio \
-lrte_pci -lrte_bus_pci -lrte_bus_vdev -lrte_lpm -lrte_pdump \
-Wl,--no-whole-archive -lrt -lm -ldl -lcrypto
到目前为止我已经尝试过:
- 使用 Makefile 系统验证链接成功
- 通过在链接 Meson 构建时添加适当的库路径,确保没有“找不到库”问题
- 我还不想将它移到 DPDK 的应用程序文件夹中并为其创建 Meson 构建文件(尚未学习)。
因此,请帮助解决此链接问题(这似乎是与-Wl
标志选项链接相关的一般问题)。
谢谢!:)
编辑:更新的错误日志
cc -D DPVS_MAX_SOCKET=1 -D DPVS_MAX_LCORE=3 -D CONFIG_DPVS_TRACING \
-D CONFIG_DPVS_NEIGH_DEBUG -D CONFIG_DPVS_IPVS_DEBUG -D DPVS_CFG_PARSER_DEBUG \
-D CONFIG_DPVS_IP_HEADER_DEBUG -D CONFIG_DPVS_PDUMP \
-D CONFIG_DPVS_IPSET_DEBUG -D CONFIG_MSG_DEBUG \
-include /home/anshul/loadbalancer/dpdk-stable-18.11.10/sdk/build/include/rte_config.h -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 \
-D __DPVS__ -DDPVS_VERSION=\"1.8-4\" \
-DDPVS_BUILD_DATE=\"2021.01.25.10:11:27\" \
-Werror -Wstrict-prototypes -Wmissing-prototypes \
-mcmodel=medium -fgnu89-inline -Wno-format-truncation \
-Wno-stringop-truncation -Wstringop-overflow=0 -g -O0 \
-D DEBUG -rdynamic \
-I /home/anshul/loadbalancer/dpdk-stable-18.11.10/sdk/build/include \
-I /home/anshul/loadbalancer/dpvs/src//../include \
-L /home/anshul/loadbalancer/dpdk-stable-18.11.10/sdk/build/lib \
-L /home/anshul/loadbalancer/dpdk-stable-18.11.10/sdk/build/lib/x86_64-linux-gnu/ \
-L /home/anshul/loadbalancer/dpdk-stable-18.11.10/sdk/build/lib/x86_64-linux-gnu/dpdk/pmds-18.11 \
-Wl,--no-as-needed -fvisibility=default \
-Wl,--whole-archive -lrte_pmd_vmxnet3 -lrte_pmd_i40e -lrte_pmd_ixgbe -lrte_pmd_e1000 -lrte_pmd_bnxt -lrte_pmd_ring -lrte_pmd_bond -lrte_ethdev -lrte_ip_frag \
-Wl,--whole-archive -lrte_hash -lrte_kvargs \
-Wl,-lrte_mbuf -lrte_eal \
-Wl,-lrte_mempool -lrte_ring -lrte_cmdline -lrte_cfgfile -lrte_kni -lrte_mempool_ring -lrte_timer -lrte_net \
-Wl,-lrte_pmd_virtio -lrte_pci -lrte_bus_pci -lrte_bus_vdev -lrte_lpm -lrte_pdump \
-Wl,--no-whole-archive -lrt -lm -ldl -lcrypto \
-Wl,-rpath,/home/anshul/loadbalancer/dpdk-stable-18.11.10/sdk/build/lib/x86_64-linux-gnu/ -lpthread -lnuma /home/anshul/loadbalancer/dpvs/src/cfgfile.o ... -o dpvs
/home/anshul/loadbalancer/dpvs/src/netif.o: In function `get_bond_status':
/home/anshul/loadbalancer/dpvs/src/netif.c:4738: undefined reference to `rte_eth_bond_link_monitoring_get'
/home/anshul/loadbalancer/dpvs/src/netif.c:4739: undefined reference to `rte_eth_bond_link_down_prop_delay_get'
/home/anshul/loadbalancer/dpvs/src/netif.c:4740: undefined reference to `rte_eth_bond_link_up_prop_delay_get'
/home/anshul/loadbalancer/dpvs/src/netif.o: In function `set_bond':
/home/anshul/loadbalancer/dpvs/src/netif.c:5030: undefined reference to `rte_eth_bond_link_down_prop_delay_set'
/home/anshul/loadbalancer/dpvs/src/netif.c:5039: undefined reference to `rte_eth_bond_link_up_prop_delay_set'
collect2: error: ld returned 1 exit status
Makefile:71: recipe for target 'dpvs' failed
make[1]: *** [dpvs] Error 1
make[1]: Leaving directory '/home/anshul/loadbalancer/dpvs/src'
Makefile:33: recipe for target 'all' failed
make: *** [all] Error 1
更新:当前使用的选项dpdk.mk
是:
CFLAGS += -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
LIBS += -L $(DPDKDIR)/lib
LIBS += -L $(DPDKDIR)/lib/x86_64-linux-gnu/
LIBS += -L $(DPDKDIR)/lib/x86_64-linux-gnu/dpdk/pmds-20.11
LIBS += -Wl,--no-as-needed -fvisibility=default \
-Wl,--whole-archive -lrte_net_vmxnet3 -lrte_net_i40e -lrte_net_ixgbe \
-lrte_net_e1000 -lrte_net_bnxt -lrte_net_ring -lrte_ip_frag \
-Wl,--whole-archive -lrte_hash -lrte_kvargs -Wl,-lrte_mbuf -lrte_eal \
-Wl,--whole-archive -l:librte_net_bond.a -l:librte_ethdev.a \
-Wl,-lrte_mempool -lrte_ring -lrte_cmdline -lrte_cfgfile -lrte_kni \
-lrte_mempool_ring -lrte_timer -lrte_net -Wl,-lrte_net_virtio \
-lrte_pci -lrte_bus_pci -lrte_bus_vdev -lrte_lpm -lrte_pdump \
-Wl,--no-whole-archive -lrt -lm -ldl -lcrypto -lrte_telemetry
LIBS += -Wl,-rpath,$(DPDKDIR)/lib/x86_64-linux-gnu/
概括:
-DRTE_COMPILE_TIME_CPUFLAGS=RTE_CPUFLAG_SSE,RTE_CPUFLAG_SSE2,RTE_CPUFLAG_SSE3,RTE_CPUFLAG_SSSE3,RTE_CPUFLAG_SSE4_1,RTE_CPUFLAG_SSE4_2
从中删除CFLAGS
以避免重新定义错误。- 更新了
LIBS
变量中的库路径以反映 SDK 的路径。SDK 文件夹 (DPDKDIR
) 是ninja install
安装文件和库的文件夹。 -Wl,-rpath,$(DPDKDIR)/lib/x86_64-linux-gnu/
为引用某些库的杂散问题添加了选项*.so.11
-l:librte_net_bond.a -l:librte_ethdev.a
使用选项链接到用于绑定和 ethdev 的静态库。
解决方案
您面临的问题是由于不当使用库链接。最简单的解决方案是
- 下载支持介子的 DPDK 18.11.11 LTS。
- 构建 dpdk 库并安装到所需的路径。
- 修改 dpvs
src/dpdk.mk
以通过 pkg-conf 检查 libdpdk - 修改
src/makefile
以适应 DPDK 库的更改
在第 3.24 节使用安装的 DPDK 构建应用程序中简要提到了这些步骤的说明
[EDIT-1] 注意:由于@Anshul 对 Makefile 所做的更改没有更新,因此我创建了一个推送请求来支持相同的内容。
src/Makefile 的差异
index 02f288c..f2aefdb 100644
--- a/src/Makefile
+++ b/src/Makefile
@@ -34,10 +34,14 @@ DATE_STRING := $(shell date +%Y.%m.%d.%H:%M:%S)
# same path of THIS Makefile
SRCDIR := $(dir $(realpath $(firstword $(MAKEFILE_LIST))))
+ifeq ($(shell pkg-config --exists libdpdk && echo 0),0)
+else
ifeq ($(RTE_SDK),)
$(error "The variable RTE_SDK is not defined.")
endif
include $(RTE_SDK)/mk/rte.vars.mk
+LIBS += -lpthread -lnuma
+endif
include $(SRCDIR)/config.mk
include $(SRCDIR)/dpdk.mk
@@ -62,7 +66,6 @@ else
CFLAGS += -rdynamic
endif
-LIBS += -lpthread -lnuma
src/dpdk.mk 的差异
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
+ifeq ($(shell pkg-config --exists libdpdk && echo 0),0)
+
+CFLAGS += -DALLOW_EXPERIMENTAL_API -static $(shell pkg-config --cflags libdpdk)
+LIBS += $(shell pkg-config --libs --static libdpdk)
+
+else
ifeq ($(RTE_SDK),)
$(error "The variable RTE_SDK is not defined.")
@@ -58,3 +64,4 @@ LIBS += -Wl,--whole-archive -lrte_pmd_mlx5 -Wl,--no-whole-archive
LIBS += -libverbs -lmlx5 -lmnl
endif
+endif
推荐阅读
- soap-client - 具有 SSL 的 IBM IIB 10 SOAPRequest 节点
- angularjs - 我应该如何在 AngularJS 项目中包含 aws-appsync
- javascript - 拖放时更改鼠标光标
- r - ggplot 对连续变量的轴部分应用不同的缩放比例
- python - 用于分类的文本预处理 - 机器学习
- html - 响应式侧边栏上的响应式图像
- google-app-maker - 从 Google Drive 启动 Appmaker 文档审批
- tensorflow - 为什么不使用输出张量的最大值而不是 Softmax 函数?
- c# - 如何使用 Chrome 在 SeleniumWebdriver 中设置性能日志记录
- vim - vimgrep 根据 vim 的路径变量