xdp-project / xdp-tools

Utilities and example programs for use with XDP
Other
661 stars 144 forks source link

Makefile does not install libbpf libraries into local machine. #407

Open WildbeestSingh opened 8 months ago

WildbeestSingh commented 8 months ago

Problem statement: The xdp-tools/Makefile does not install libbpf libraries into local machine.

However, it does install the libxdp libraries into the local machine.

Steps: cd ../../../samples/bpf/xdp-tools/ $ FORCE_SUBDIR_LIBBPF=1 ./configure $ make $ sudo make install

I modified the Makefile in ..samples/bpf/ to incorporate the libbpf library from xdp-tools/lib/libbpf/src.

While I successfully built my program using the libbpf library generated under xdp-tools/lib/libbpf/src, I encountered runtime failures due to the program's dependence on the same library during runtime.

Consequently, I manually transferred all the libbpf libraries from the xdp-tools/lib/libbpf/src directory to the local machine, enabling my program to locate them at runtime.

tohojo commented 8 months ago

If you build against the libbpf library in lib/, libxdp will be statically linked against that library version, and you won't have to copy it anywhere.

I would recommend linking against the system libbpf version instead of messing around with hacking the Makefile to copy the libbpf library.

WildbeestSingh commented 8 months ago

So you are suggesting me to build my program against the libbpf from the system and libxdp library from the xdp-tools/lib/libxdp?.

tohojo commented 8 months ago

Jsingh @.***> writes:

So you are suggesting me to build my program against the libbpf from the system and libxdp library from the xdp-tools/lib/libxdp?.

Yes, as long as you are also linking libxdp against the system libbpf (which the configure file should do by default), this will work just fine.

WildbeestSingh commented 8 months ago

Alright, btw, do you have any references for the samples/bpf/Makefile to use libbpf from xdp-tools/ instead from (kernel-sources)/tools/lib/bpf/ ?.

tohojo commented 8 months ago

Jsingh @.***> writes:

Alright, btw, do you have any references for the samples/bpf/Makefile to use libbpf from xdp-tools/ instead from (kernel-sources)/tools/lib/bpf/ ?.

I don't know if that is possible, but in general samples/bpf in the kernel tree is unmaintained and slowly bitrotting. So I would not suggest using it, really. What utility from there are you trying to use?

WildbeestSingh commented 8 months ago

Basically, I want to use the libbpf and libxdp libraries from the xdp-tools/ in the samples/bpf/Makefile file.

tohojo commented 8 months ago

Jsingh @.***> writes:

Basically, I want to use the libbpf and libxdp libraries from the xdp-tools/ in the samples/bpf/Makefile file.

Yes, but why? Which files from samples/bpf do you want to make use of?

WildbeestSingh commented 7 months ago

Sorry for the late reply. I'm not using any files from samples/bpf/ in my xdp application(under samples/bpf/). As my xdp application requires the libbpf and libxdp libraries and I want to utilize the existing Makefile(samples/bpf/). But now as I'm using the above two libraries from the xdp-tools/ thus no longer dependent on system/kernel tree libraries. Therefore, now I can move my application to any other path.