Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to cross-compile programs from amd64 to arm64 #144

Open
bartsmykla opened this issue Feb 20, 2023 · 6 comments
Open

How to cross-compile programs from amd64 to arm64 #144

bartsmykla opened this issue Feb 20, 2023 · 6 comments

Comments

@bartsmykla
Copy link

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
@anakryiko
Copy link
Member

@wangjie could you please help? I'm not very familiar with cross-compilation, unfortunately.

@setNull
Copy link

setNull commented Apr 26, 2023

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.

@JiaHuann
Copy link

the same here,thanks

@JiaHuann
Copy link

JiaHuann commented Aug 31, 2023

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.

@anakryiko
Copy link
Member

can you submit a clear PR with only necessary changes?

@JiaHuann
Copy link

can you submit a clear PR with only necessary changes?

Ok,I will do it recently.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants