I'm trying to compile the sample bpf program in Linux source code. So I downloaded the current kernel source code and entered samples/bpf folder
apt source linux
cd linux-*/samples/bpf
Then I tried to compile a sample program with gcc:
# gcc sock_example.c
sock_example.c:29:10: fatal error: bpf/bpf.h: No such file or directory
29 | #include <bpf/bpf.h>
| ^~~~~~~~~~~
compilation terminated.
And I'm unable to find bpf/bpf.h with apt-file
# apt-file find bpf/bpf.h
(no output)
What was wrong?
You need to install libbpf:
git clone --depth 1 https://github.com/libbpf/libbpf
cd src
sudo make install
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With