Can't cross compile for Raspberry-pi / M1 Mac

Trying to cross-compile from m1 Mac to a Raspberry Pi 3b
so I did use
"cargo build --target aarch64-unknown-linux-gnu"


error[E0463]: can't find crate for std
= note: the aarch64-unknown-linux-gnu target may not be installed
= help: consider downloading the target with rustup target add aarch64-unknown-linux-gnu

error: cannot find macro println in this scope
--> src/
2 | println!("Hello, Docker 2!");
| ^^^^^^^

error: requires sized lang_item


this error message pops up even I downloaded aarch64-unknown-linux-gnu

Overall I'm lost atm

You did run rustup target add aarch64-unknown-linux-gnu?

1 Like

Note that Rust/Cargo doesn't support cross-compilation of binaries and dynamic libraries out of the box (it can only make object files/static libraries). You will have to find and install a cross-linker and Linux system libraries on your Mac.

This is much easier with zigbuild or just compile in a virtual machine.

1 Like

Thanks all of your helps guys :slight_smile:
Finally I find out the problems between my brew downloaded rust and rustup update version. The rustc version had error to read other toolchanins. So I uninstalled rust by using "brew uninstall rust" and reinstall from the official site. And it work!! Thanks a lot again. Have a good one!

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.