path: root/mk
diff options
authorDavid Marchand <>2015-12-04 18:11:03 +0100
committerThomas Monjalon <>2015-12-04 20:10:35 +0100
commitebfd02be8a956536d34d8bf57dc17d152dfaf272 (patch)
tree5f6f7feef9a47fd1697ed43939267ac9567ac538 /mk
parent992ecdd839abaadda629295ed565e08618cc060c (diff)
mk: fix objects and libraries order when linking
The initial problem has been seen while building mlx4 pmd as a shared library on Ubuntu 14.04 (gcc 4.8.4-2ubuntu1~14.04). Resulting .so will lack the DT_NEEDED entry for libibverbs: marchand@ubuntu1404:~/dpdk$ ldd ./build/lib/ => (0x00007fff87ebb000) => /lib/x86_64-linux-gnu/ (0x00007f2ced21a000) /lib64/ (0x00007f2ced821000) And trying to load it in testpmd triggers this error: [...] EAL: undefined symbol: ibv_query_port [...] After some strace, the problem comes from the --as-needed option passed to the linker. It is safer to specify libraries we depend on after the objects we are linking into a shared library, especially when the linker is invoked with options like --as-needed. Fixes: bef06a8a0655 ("mk: set library dependencies in shared object file") Signed-off-by: David Marchand <> Acked-by: Adrien Mazarguil <>
Diffstat (limited to 'mk')
1 files changed, 1 insertions, 1 deletions
diff --git a/mk/ b/mk/
index 06a1519..1f1b6e1 100644
--- a/mk/
+++ b/mk/
@@ -82,7 +82,7 @@ O_TO_A_DO = @set -e; \
$(O_TO_A) && \
echo $(O_TO_A_CMD) > $(call exe2cmd,$(@))
-O_TO_S = $(LD) $(_CPU_LDFLAGS) $(EXTRA_LDFLAGS) $(LDLIBS) -shared $(OBJS-y) \
+O_TO_S = $(LD) $(_CPU_LDFLAGS) $(EXTRA_LDFLAGS) -shared $(OBJS-y) $(LDLIBS) \
-Wl,-soname,$(LIB) -o $(LIB)
O_TO_S_STR = $(subst ','\'',$(O_TO_S)) #'# fix syntax highlight
O_TO_S_DISP = $(if $(V),"$(O_TO_S_STR)"," LD $(@)")