|
|
|
@ -61,31 +61,25 @@ Current installation options:
|
|
|
|
|
|
|
|
|
|
**2、x86_64-pc-windows-gnu**
|
|
|
|
|
|
|
|
|
|
该类型的C++ 环境其实官方也有说明 [Other Rust Installation Methods](https://forge.rust-lang.org/infra/other-installation-methods.html#other-rust-installation-methods).
|
|
|
|
|
相比于msvc版本来说,gnu版本具有更轻量,更靠近linux的优势
|
|
|
|
|
|
|
|
|
|
个人习惯使用 [mingw-w64 官网](https://www.mingw-w64.org/) , 当然你也可以选择[win-builds](http://win-builds.org/).
|
|
|
|
|
### 更新和卸载
|
|
|
|
|
|
|
|
|
|
为了方便初学者使用 这里提供一个免安装的的方式 [mingw-w64下载](https://sourceforge.net/projects/mingw-w64/files/),演示选择的 `x86_64-posix-seh` 对于学习者,初次安装不需要纠结什么类别,因为切换版本很方便。下载完压缩包并解压,把压缩包下的 `/bin` 目录添加到 环境`Path` 即可:
|
|
|
|
|
首先,根据[MSYS2官网](https://www.msys2.org/)配置MSYS
|
|
|
|
|
|
|
|
|
|
<img alt="" src="/img/mingw-w64-download.png" class="center" />
|
|
|
|
|
若您觉得下载太慢,可以试试由[Caviar-X](https://github.com/Caviar-X)提供的[代理](https://github.pigeons.icu/msys2/msys2-installer/releases/download/2021-11-30/msys2-x86_64-20211130.exe)
|
|
|
|
|
|
|
|
|
|
1、验证 c++ 环境
|
|
|
|
|
``` shell
|
|
|
|
|
PS C:\Users\Hehongyuan> c++ -v
|
|
|
|
|
Using built-in specs.
|
|
|
|
|
COLLECT_GCC=C:\ENV\mingw64\bin\c++.exe
|
|
|
|
|
COLLECT_LTO_WRAPPER=C:/ENV/mingw64/bin/../libexec/gcc/x86_64-w64-mingw32/8.1.0/lto-wrapper.exe
|
|
|
|
|
Target: x86_64-w64-mingw32
|
|
|
|
|
Configured with: xxxxxxxxxxxxxx
|
|
|
|
|
gcc version 8.1.0 (x86_64-posix-seh-rev0, Built by MinGW-W64 project)
|
|
|
|
|
在安装mingw-toolchain后,请将`%MSYS安装路径%\mingw64\bin`添加到系统变量`PATH`中
|
|
|
|
|
|
|
|
|
|
配置好后,在MSYS中输入
|
|
|
|
|
```bash
|
|
|
|
|
$ curl https://sh.rustup.rs -sSf | sh
|
|
|
|
|
```
|
|
|
|
|
来安装rustup
|
|
|
|
|
|
|
|
|
|
2、安装 Rust 注意选择 `Customize installation` 并设置 `host triple` 为 `x86_64-pc-windows-gnu`
|
|
|
|
|
之后,根据以下输出进行配置
|
|
|
|
|
|
|
|
|
|
``` shell
|
|
|
|
|
PS C:\Users\Hehongyuan> rustup-init.exe
|
|
|
|
|
......
|
|
|
|
|
```text
|
|
|
|
|
Current installation options:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -99,46 +93,58 @@ Current installation options:
|
|
|
|
|
3) Cancel installation
|
|
|
|
|
>2
|
|
|
|
|
|
|
|
|
|
I m going to ask you the value of each of these installation options.
|
|
|
|
|
I'm going to ask you the value of each of these installation options.
|
|
|
|
|
You may simply press the Enter key to leave unchanged.
|
|
|
|
|
|
|
|
|
|
Default host triple? [x86_64-pc-windows-msvc]
|
|
|
|
|
x86_64-pc-windows-gnu
|
|
|
|
|
|
|
|
|
|
Default toolchain? (stable/beta/nightly/none) [stable]
|
|
|
|
|
|
|
|
|
|
stable
|
|
|
|
|
|
|
|
|
|
Profile (which tools and data to install)? (minimal/default/complete) [default]
|
|
|
|
|
complete
|
|
|
|
|
|
|
|
|
|
```
|
|
|
|
|
Modify PATH variable? (Y/n)
|
|
|
|
|
Y
|
|
|
|
|
|
|
|
|
|
> windows上安装过程较为麻烦,因此我们专门写了一篇文章来讲解相关的安装过程,请参考:[Windows安装](https://blog.csdn.net/erlib/article/details/121684998?spm=1001.2014.3001.5501).
|
|
|
|
|
|
|
|
|
|
Current installation options:
|
|
|
|
|
|
|
|
|
|
### 更新和卸载
|
|
|
|
|
|
|
|
|
|
通过 `rustup` 安装 Rust 后,更新到最新版本很简单。在终端中运行以下更新命令:
|
|
|
|
|
default host triple: x86_64-pc-windows-gnu
|
|
|
|
|
default toolchain: stable
|
|
|
|
|
profile: complete
|
|
|
|
|
modify PATH variable: yes
|
|
|
|
|
|
|
|
|
|
```console
|
|
|
|
|
$ rustup update
|
|
|
|
|
1) Proceed with installation (default)
|
|
|
|
|
2) Customize installation
|
|
|
|
|
3) Cancel installation
|
|
|
|
|
>
|
|
|
|
|
```
|
|
|
|
|
之后,按下1,等待
|
|
|
|
|
|
|
|
|
|
要卸载 `Rust` 和 `rustup`,在终端中运行以下卸载命令:
|
|
|
|
|
完成后,您就已经安装了 `Rust` 和 `rustup`
|
|
|
|
|
|
|
|
|
|
```console
|
|
|
|
|
$ rustup self uninstall
|
|
|
|
|
要卸载 `Rust` 和 `rustup`,在MSYS中运行以下卸载命令:
|
|
|
|
|
|
|
|
|
|
```bash
|
|
|
|
|
rustup self uninstall
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
### 检查安装是否成功
|
|
|
|
|
|
|
|
|
|
检查是否正确安装了 Rust,可打开终端并输入下面这行, 此时能看到最新发布的稳定版本的版本号、提交哈希值和提交日期:
|
|
|
|
|
|
|
|
|
|
```console
|
|
|
|
|
```bash
|
|
|
|
|
$ rustc -V
|
|
|
|
|
rustc 1.56.1 (59eed8a2a 2021-11-01)
|
|
|
|
|
$ cargo -V
|
|
|
|
|
cargo 1.57.0 (b2e52d7ca 2021-10-21)
|
|
|
|
|
```
|
|
|
|
|
> 注: 若发现版本号不同,以您的版本号为准
|
|
|
|
|
|
|
|
|
|
恭喜,你已成功安装 Rust!如果没看到此信息,并且你使用的是 Windows,请检查 Rust 是否在 `%PATH%` 系统变量中。如果都正确,但 `Rust` 仍然无法正常工作,那么你可以在很多地方获得帮助。最简单的是**加入Rust编程学院这个大家庭,QQ群:1009730433**.
|
|
|
|
|
恭喜,你已成功安装 Rust!如果没看到此信息,并且你使用的是 Windows,请检查 Rust 或 `%USERPROFILE%\.cargo\bin` 是否在 `%PATH%` 系统变量中。如果都正确,但 `Rust` 仍然无法正常工作,那么你可以在很多地方获得帮助。最简单的是**加入Rust编程学院这个大家庭,QQ群:1009730433**.
|
|
|
|
|
|
|
|
|
|
### 本地文档
|
|
|
|
|
|
|
|
|
|