lizrice / learning-ebpf

Learning eBPF, published by O'Reilly - out now! Here's where you'll find a VM config for the examples, and more

Home Page:https://www.amazon.com/Learning-eBPF-Programming-Observability-Networking/dp/1098135121

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Compilation Error Chapter5

naftalyava opened this issue · comments

I have libbpf and bpftool installed, and generally have no issues compiling some other code.

But I am unable to compile code for chapter 5.

~/dev/eBPF/learning-ebpf/chapter5$ make
clang \
    -target bpf \
        -D __TARGET_ARCH_x86 \
    -Wall \
    -O2 -g -o hello-buffer-config.bpf.o -c hello-buffer-config.bpf.c
hello-buffer-config.bpf.c:27:31: error: expected identifier
int BPF_KPROBE_SYSCALL(hello, const char *pathname)
                              ^
hello-buffer-config.bpf.c:36:59: error: use of undeclared identifier 'pathname'
   bpf_probe_read_user_str(&data.path, sizeof(data.path), pathname);
                                                          ^
hello-buffer-config.bpf.c:45:26: error: use of undeclared identifier 'ctx'
   bpf_perf_event_output(ctx, &output, BPF_F_CURRENT_CPU, &data, sizeof(data));   
                         ^
3 errors generated.
make: *** [Makefile:15: hello-buffer-config.bpf.o] Error 1

Duplicate of #12