aquasecurity / libbpfgo

eBPF library for Go. Powered by libbpf.
Apache License 2.0
731 stars 94 forks source link

Building static libbpfgo fails in Makefile running in v0.2.5: /usr/bin/ld cannot found lXX #240

Open zbh255 opened 2 years ago

zbh255 commented 2 years ago

Run command make -C selftest/perfbuffers or make selftest-static-run

Out Error

/usr/lib/golang/pkg/tool/linux_amd64/link: running clang failed: exit status 1
/usr/bin/ld: cannot found -lelf
/usr/bin/ld: cannot found -lz
/usr/bin/ld: cannot found -lelf
/usr/bin/ld: cannot found -lz
/usr/bin/ld: cannot found -lelf
/usr/bin/ld: cannot found -lz
/usr/bin/ld: cannot found -lc
clang-14: error: linker command failed with exit code 1 (use -v to see invocation)

Linux Version

Fedora release 36 (Thirty Six)
Linux fedora 5.17.5 #2 SMP PREEMPT Sun Sep 4 19:24:15 CST 2022 x86_64 x86_64 x86_64 GNU/Linux

Libbpf Version

Name         : libbpf
Epoch        : 2
Version      : 0.7.0
Release      : 3.fc36
Architecture : x86_64
Size         : 356 k
Source       : libbpf-0.7.0-3.fc36.src.rpm
rafaeldtinoco commented 2 years ago

Possible example on how to "solve" issues like this in Makefile: https://github.com/aquasecurity/tracee/blob/main/Makefile#L50

sunhaotian0122 commented 2 years ago

I have the same problem, have you solved it? Architecture:ARM64 clang version:clang-12

geyslan commented 2 years ago

@zbh255 @sunhaotian0122 In the meantime you can try: https://github.com/aquasecurity/libbpfgo#contributing

geyslan commented 5 months ago

@zbh255 Would you mind trying against main? We've merged related fixes: https://github.com/aquasecurity/libbpfgo/pull/431