Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can't compile sample bpf program, bpf/bpf.h is missing

Tags:

c

linux

bpf

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?

like image 901
daisy Avatar asked May 22 '26 23:05

daisy


1 Answers

You need to install libbpf:

git clone --depth 1 https://github.com/libbpf/libbpf
cd src
sudo make install
like image 122
pchaigno Avatar answered May 24 '26 17:05

pchaigno



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!