Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

编译连接时有可能选取错误的dpdk lib路径 #1010

Open
lxchx opened this issue Dec 25, 2024 · 0 comments
Open

编译连接时有可能选取错误的dpdk lib路径 #1010

lxchx opened this issue Dec 25, 2024 · 0 comments

Comments

@lxchx
Copy link

lxchx commented Dec 25, 2024

./src/Makefile的规则中,如果pkg-config找到了libssl库,就会在编译时连接libssl库。在我的编译环境下,LIBS会追加-L/usr/lib64 -lssl -ldl -lz -lgssapi_krb5 -lkrb5 -lcom_err -lk5crypto -lcrypto -ldl -lz。然后再通过include $(SRCDIR)/dpdk.mk连接dpdk库。

在最后编译连接dpvs时,由于-L/usr/lib64在dpdk lib追加的参数之前,会导致dpdk的libs也会优先选择/usr/lib64下的文件,而不是随后指定的特定dpdklib路径,当那个路径安装了dpdklib时就连接了错误的dpdk静态库。

一个比较简单的修复方法就是在Makefile中调换引入libssl和dpdklib的顺序。

diff --git a/src/Makefile b/src/Makefile
index 62d8cbb..e43f26d 100644
--- a/src/Makefile
+++ b/src/Makefile
@@ -37,14 +37,14 @@ SRCDIR := $(dir $(realpath $(firstword $(MAKEFILE_LIST))))
 # Addtional libs below are needed when using dynamic link.
 LIBS += -lpthread -lnuma -lrt -lm -ldl -lcrypto
 
+include $(SRCDIR)/config.mk
+include $(SRCDIR)/dpdk.mk
+
 ifeq ($(shell pkg-config --exists libssl && echo 0),0)
 CFLAGS += $(shell pkg-config --cflags libssl)
 LIBS += $(shell pkg-config --static --libs libssl)
 endif
 
-include $(SRCDIR)/config.mk
-include $(SRCDIR)/dpdk.mk
-
 INCDIRS += -I $(SRCDIR)/../include
 
 # for dpvs main program.

不过注意到引入libssl的commit是 3994ca9 ,我手头没有合适的环境,不知道这个修复会不会破坏该commit所说的环境的编译兼容性。或者pkg-config的使用上有没有更好的实践可以避免这个问题?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant