linux-observability-with-bpf make: *** No rule to make target ‘/kernel-src/samples/bpf/bpf_load.c‘

Ubuntu 18.04.2 LTS 环境下

git clone https://github.com/bpftools/linux-observability-with-bpf.git

进入 linux-observability-with-bpf/chapter-2/hello_world

阅读README.md后执行make bpfload,报错

make: *** No rule to make target '/kernel-src/samples/bpf/bpf_load.c', needed by 'build'.  Stop.
进入官网 bpftools / linux-observability-with-bpf

找到

Linux Observability with BPF code examples 然后点开Ubuntu 18.04,进行环境配置

依次执行如下命令:

sudo apt update
sudo apt install build-essential git make libelf-dev clang strace tar bpfcc-tools linux-headers-$(uname -r) gcc-multilib

cd /tmp
git clone --depth 1 git://kernel.ubuntu.com/ubuntu/ubuntu-bionic.git


sudo mv ubuntu-bionic /kernel-src
cd /kernel-src/tools/lib/bpf
sudo make && sudo make install prefix=/usr/local

sudo mv /usr/local/lib64/libbpf.* /lib/x86_64-linux-gnu/

 之所以选Ubuntu 18.04,是因为 ebpf对内核版本有要求,最好是 >=5.0.0。

环境搭建好之后,那就可以到刚才的目录下执行make bpfload

会出现 monitor-exec  可执行文件。

linux-observability-with-bpf make: *** No rule to make target ‘/kernel-src/samples/bpf/bpf_load.c‘_第1张图片

 

你可能感兴趣的:(linux内核,安全,ebpf,linux)