asm/types.h Error during compilation of ebpf code

970 views Asked by At

Here i am trying to compile a eBPF code. and used the following command for compilation. command: clang -O2 -target bpf -c your_ebpf_program.c -o your_ebpf_program.o

error: In file included from my_program.c:2:/usr/include/linux/bpf.h:11:10: fatal error: 'asm/types.h' file not found#include <asm/types.h> ^~~~~~~~~~~~~1 error generated.

I used clang as a compiler for compilation. All the required libraries are downloaded and yet got an error stating asm/types.h is not found. All the linux header files are updated.

2

There are 2 answers

0
Dylan Reimerink On BEST ANSWER

You might need to install additional kernel headers. On Ubuntu for example you can do so by executing

apt install linux-headers-`uname -r`

Apparently on some platforms you might need to symlink a directory as well. But I am not sure that is always required. Source 1 Source 2

sudo ln -s /usr/include/x86_64-linux-gnu/asm /usr/include/asm
0
Alex0x090 On

Try to install Libbpf:

sudo apt update -y
sudo apt-get -y install libbpf-dev