rust笔记


Table of Contents

安装

  • 安装

    └──╼ brew install rustup
    └──╼ rustup-init
    ......
    1) Proceed with installation (default)
    2) Customize installation
    3) Cancel installation
    >1
  • 配置 rust 目录

    └──╼ mkdir $HOME/repo/rust
    └──╼ mv $HOME/.rustup $HOME/repo/rust/rustup
    └──╼ mv $HOME/.cargo $HOME/repo/rust/cargo

    写入 .bashrc 文件

    export RUSTUP_HOME=$HOME/repo/rust/rustup
    export CARGO_HOME=$HOME/repo/rust/cargo
    export PATH=$PATH:$HOME/repo/rust/cargo/bin
  • 验证

    └──╼ source .bashrc
    └──╼ cargo --version
    cargo 1.46.0 (149022b1d 2020-07-17)

更新

最近在测试时发现无法安装 tauri-app, 需要更新 cargo

Caused by:
  failed to parse the `edition` key

Caused by:
  this version of Cargo is older than the `2021` edition, and only supports `2015` and `2018` editions.

解决方式

└──╼ rustc --version
rustc 1.46.0 (04488afe3 2020-08-24)
└──╼ rustup update stable
...
└──╼ rustc --version
rustc 1.64.0 (a55dd71d5 2022-09-19)

交叉编译

brew install FiloSottile/musl-cross/musl-cross
rustup target add x86_64-unknown-linux-musl

添加配置 $CARGO_HOME/config.toml

[target.x86_64-unknown-linux-musl]
linker = "x86_64-linux-musl-gcc"
cargo build --target=x86_64-unknown-linux-musl
作者: honmaple
链接: https://honmaple.me/articles/2020/09/rust笔记.html
版权: CC BY-NC-SA 4.0 知识共享署名-非商业性使用-相同方式共享4.0国际许可协议
wechat
alipay

加载评论