主要流程:

  1. https://forge.rust-lang.org/infra/other-installation-methods.html

下载Linux版本Rust x86_64-unknown-linux-gnu

  1. 运行脚本安装,输入1,回车。1) Proceed with installation (default)
  2. 查看目标 $rustc --print target-list
  3. $rustup target add armv7-unknown-linux-gnueabihf
  4. $cat ~/.cargo/config结果如下

    1. [target.armv7-unknown-linux-gnueabihf]
    2. linker = "arm-linux-gnueabihf-gcc"
  5. 交叉编译Debug版本

cargo build --target=armv7-unknown-linux-gnueabihf

  1. 交叉编译Release版本

cargo build --target=armv7-unknown-linux-gnueabihf --release

其他命令:

更新Rust:rustup update
卸载Rust:rustup self uninstall

更改为清华源

  1. [source.crates-io]
  2. replace-with = 'tuna'
  3. [source.tuna]
  4. registry = "https://mirrors.tuna.tsinghua.edu.cn/git/crates.io-index.git"

解决:Blocking waiting for file lock on package cache

rm ~/.cargo/.package-cache