win10安装Rust+VS Code配置Rust环境

  • 笔记日期:2022年1月20日
  • Rust版本:1.58.0

Rust Playground(在线IDE):https://play.rust-lang.org/

下载rustup

进入:https://www.rust-lang.org/tools/install

点击“DOWNLOAD RUSTUP-INIT.EXE(64-BIT)”下载rustup并安装。默认安装会帮助我们安装:

  • stable-x86_64-pc-windows-msvc
  • cargo
  • clippy
  • rust-docs
  • rust-std
  • rustc
  • rustfmt

下载vs code

进入:https://code.visualstudio.com/

点击“Download for Windows”下载vs code并安装。

vs code配置

vs code中安装如下扩展:

  • rust-analyzer
  • CodeLLDB

常见问题

cargo run时报错:

PS D:\projects\hello_world> cargo run
   Compiling hello_world v0.1.0 (D:\projects\hello_world)
error: linker `link.exe` not found
  |
  = note: program not found

note: the msvc targets depend on the msvc linker but `link.exe` was not found

note: please ensure that VS 2013, VS 2015, VS 2017 or VS 2019 was installed with the Visual C++ option

error: could not compile `hello_world` due to previous error

解决办法:在终端依次运行如下两条指令:

rustup toolchain install stable-x86_64-pc-windows-gnu
rustup default stable-x86_64-pc-windows-gnu
posted @ 2022-01-20 13:07  鱼又悲  阅读(1704)  评论(0编辑  收藏  举报