xdp-project / xdp-tools

Utilities and example programs for use with XDP

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

ld cannot found libxdp

e3xf opened this issue · comments

Hello, I have an old project that uses XDP via the deprecated libbpf functions. I'm trying to update this project to enable it to use the newer libxdp, but the compilation fails to find libxdp. I have installed it though the debian packages at https://packages.debian.org/trixie/libxdp-dev.
This is the of error that I get.

[...]
c -g -Wall -I../libbpf/src/build/usr/include/ -I../libbpf/include/ -L../libbpf/src -o ppve ppve_args.o ppve_xdp.o ppve_gen.c ppve.c -l:libbpf.a -lelf -lz
/usr/bin/ld: ppve_xdp.o: in function `ppve_xdp__load':
/root/ws/src/ppve_xdp.c:57:(.text+0x276): undefined reference to `xdp_program__create'
/usr/bin/ld: /root/ws/src/ppve_xdp.c:58:(.text+0x286): undefined reference to `libxdp_get_error'
[...]

There are more lines with the same error that I omitted for simplicity.

Hello, I have build the libxdp myself, but there should not be a difference to your case. The function libxdp_get_error can be found in libxdp.c and I hope it is also included in the debian package libxdp-dev. What might be the problem:
You must build your application against libxdp, not libbpf. My compiler call for my userspace application looks like this:
gcc -g myapp.c -l xdp -L $(LIB_DIR_XDP) -o myapp
You are comiling against libbpf, it seems (-l:libbpf.a)
Also for include paths, I used the header-folder of the xdp-tools

Thank you @juerlink. Your reply guided me to be able to compile my project. In fact, libxdp.c is not included in the debian package, so I used this repository with make libxdp and, as you said, compiled the application against libxdp. I'm closing the issue now.