rust windows 交叉编译_树莓派上使用rust:交叉编译
方法一
樹莓派Zero 用的 BCM2835 是 armv6 架構的。arm-linux-gnueabihf-gcc
pacaur -S arm-linux-gnueabihf-gcc
rustup target add arm-unknown-linux-gnueabihf
Cargo 設置
需要給 cargo 的配置文件里面指定 arm-unknown-linux-gnueabihf 的 linker.
默認配置一般在 ~/.cargo/config 這里, 沒有就創一個.
[target.arm-unknown-linux-gnueabihf]
linker = "arm-linux-gnueabihf-gcc"
來告訴 cargo 在編譯到 arm-unknown-linux-gnueabihf target 的時候用之前安裝的 gcc 做 linker, 不然會默認用 cc 做 linker, 那這當然是不行的.
測試
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
總結
以上是生活随笔為你收集整理的rust windows 交叉编译_树莓派上使用rust:交叉编译的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 一行python代码值多少钱_一行pyt
- 下一篇: php如何直接使用iview,iview