libbpf-bootstrap
libbpf-bootstrap copied to clipboard
How to cross-compile programs from amd64 to arm64
I'm trying to cross-compile some of the programs built on top of libbpf-bootstrap, but I'm lacking expertise with C/C++ ecosystem. I see that support for cross-compilation was added in https://github.com/libbpf/libbpf-bootstrap/commit/7b60b4fd6c6da6af046dc6f618c771f763b6a472 I would appreciate help with:
- what are the packages I have to have installed on Ubuntu 22.04 (amd64) to cross-compile programs to arm64?
- do I have to cross-compile libelf and zlib first? If so, any hints how can I do it?
My current results:
~ CROSS_COMPILE=aarch64-linux-gnu-g make all
BINARY bind
/usr/lib/gcc-cross/aarch64-linux-gnu/11/../../../../aarch64-linux-gnu/bin/ld: cannot find -lelf: No such file or directory
/usr/lib/gcc-cross/aarch64-linux-gnu/11/../../../../aarch64-linux-gnu/bin/ld: cannot find -lz: No such file or directory
@wangjie could you please help? I'm not very familiar with cross-compilation, unfortunately.
I'm trying to cross-compile some of the programs built on top of libbpf-bootstrap, but I'm lacking expertise with C/C++ ecosystem. I see that support for cross-compilation was added in 7b60b4f I would appreciate help with:
- what are the packages I have to have installed on Ubuntu 22.04 (amd64) to cross-compile programs to arm64?
- do I have to cross-compile libelf and zlib first? If so, any hints how can I do it?
My current results:
~ CROSS_COMPILE=aarch64-linux-gnu-g make all BINARY bind /usr/lib/gcc-cross/aarch64-linux-gnu/11/../../../../aarch64-linux-gnu/bin/ld: cannot find -lelf: No such file or directory /usr/lib/gcc-cross/aarch64-linux-gnu/11/../../../../aarch64-linux-gnu/bin/ld: cannot find -lz: No such file or directory
Hi bartsmykla,
Yes, libbpf depends on libelf and libz, so you need declare where the libraries and header files can be found.
such as, make EXTRA_CFLAGS="-IXXX" EXTRA_LDFLAGS="-LXXX" ARCH=arm64.
You can get a copy of these libraries from here for quickly verification if you don't want to cross-compile them yourself.
the same here,thanks
libbpf-bootstrap-android x86 -> android aarch64. I embbed deps and add externel path to involve BTF file for android kernel,wish this can help you.
can you submit a clear PR with only necessary changes?
can you submit a clear PR with only necessary changes?
Ok,I will do it recently.