方法一
樹莓派Zero 用的 BCM2835 是 armv6 架構(gòu)的牺六。arm-linux-gnueabihf-gcc
pacaur -S arm-linux-gnueabihf-gcc
rustup target add arm-unknown-linux-gnueabihf
Cargo 設(shè)置
需要給 cargo 的配置文件里面指定 arm-unknown-linux-gnueabihf 的 linker.
默認(rèn)配置一般在 ~/.cargo/config 這里, 沒有就創(chuàng)一個.
[target.arm-unknown-linux-gnueabihf]
linker = "arm-linux-gnueabihf-gcc"
來告訴 cargo 在編譯到 arm-unknown-linux-gnueabihf target 的時候用之前安裝的 gcc 做 linker, 不然會默認(rèn)用 cc 做 linker, 那這當(dāng)然是不行的.
測試
cargo build --target=arm-unknown-linux-gnueabihf
用scp傳到樹莓派上就可以了
方法二
用cross蹲嚣,非常方便畴栖,強烈推薦!!!
# (ONCE PER BOOT)
# Start the Docker daemon, if it's not already running
sudo systemctl start docker
# MAGIC! This Just Works
#cross build --target arm-unknown-linux-musleabihf
cross build --target arm-unknown-linux-gnueabihf
# EVEN MORE MAGICAL! This also Just Works
cross test --target mips64-unknown-linux-gnuabi64
# Obviously, this also Just Works
cross rustc --target powerpc-unknown-linux-gnu --release -- -C lto