From 04f641c030281f49b7088eaf80cd4d59381af397 Mon Sep 17 00:00:00 2001 From: Caviar-X Date: Fri, 7 Jan 2022 16:48:30 +0800 Subject: [PATCH 1/5] Update installation.md --- book/contents/first-try/installation.md | 71 +++++-------------------- 1 file changed, 13 insertions(+), 58 deletions(-) diff --git a/book/contents/first-try/installation.md b/book/contents/first-try/installation.md index f74a10ef..34611f87 100644 --- a/book/contents/first-try/installation.md +++ b/book/contents/first-try/installation.md @@ -61,72 +61,27 @@ 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). - -个人习惯使用 [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` 即可: - - - -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) - -``` - -2、安装 Rust 注意选择 `Customize installation` 并设置 `host triple` 为 `x86_64-pc-windows-gnu` - -``` shell -PS C:\Users\Hehongyuan> rustup-init.exe -...... -Current installation options: - - - default host triple: x86_64-pc-windows-msvc - default toolchain: stable (default) - profile: default - modify PATH variable: yes - -1) Proceed with installation (default) -2) Customize installation -3) Cancel installation ->2 - -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] +相比于msvc版本来说,gnu版本具有更轻量,更靠近linux的优势 +### 更新和卸载 -Profile (which tools and data to install)? (minimal/default/complete) [default] +首先,根据[MSYS2官网](https://www.msys2.org/)配置MSYS +配置好后,在MSYS中输入 +```bash +curl https://sh.rustup.rs -sSf | sh ``` +来安装rustup -> windows上安装过程较为麻烦,因此我们专门写了一篇文章来讲解相关的安装过程,请参考:[Windows安装](https://blog.csdn.net/erlib/article/details/121684998?spm=1001.2014.3001.5501). - - -### 更新和卸载 +之后,根据以下输出进行配置 -通过 `rustup` 安装 Rust 后,更新到最新版本很简单。在终端中运行以下更新命令: -```console -$ rustup update -``` +配置完成后,您就已经安装了 `Rust` 和 `rustup` -要卸载 `Rust` 和 `rustup`,在终端中运行以下卸载命令: +要卸载 `Rust` 和 `rustup`,在MSYS中运行以下卸载命令: -```console -$ rustup self uninstall +```bash +rustup self uninstall ``` ### 检查安装是否成功 @@ -144,4 +99,4 @@ rustc 1.56.1 (59eed8a2a 2021-11-01) 安装Rust的同时也会在本地安装一个文档服务,方便我们离线阅读: 运行 `rustup doc` 让浏览器打开本地文档。 -每当遇到标准库提供的类型或函数不知道怎么用时,都可以在 API 文档中查找到!具体参见[在标准库寻找你想要的内容](../std/search.md) \ No newline at end of file +每当遇到标准库提供的类型或函数不知道怎么用时,都可以在 API 文档中查找到!具体参见[在标准库寻找你想要的内容](../std/search.md) From 559d4da969913de9a31a9ecdd2ba6aa24bdfe6bf Mon Sep 17 00:00:00 2001 From: Caviar-X Date: Fri, 7 Jan 2022 16:50:23 +0800 Subject: [PATCH 2/5] Update installation.md --- book/contents/first-try/installation.md | 50 +++++++++++++++++++++++-- 1 file changed, 47 insertions(+), 3 deletions(-) diff --git a/book/contents/first-try/installation.md b/book/contents/first-try/installation.md index 34611f87..62c7704e 100644 --- a/book/contents/first-try/installation.md +++ b/book/contents/first-try/installation.md @@ -69,14 +69,58 @@ Current installation options: 配置好后,在MSYS中输入 ```bash -curl https://sh.rustup.rs -sSf | sh +$ curl https://sh.rustup.rs -sSf | sh ``` 来安装rustup 之后,根据以下输出进行配置 +```text +Current installation options: + + + default host triple: x86_64-pc-windows-msvc + default toolchain: stable (default) + profile: default + modify PATH variable: yes + +1) Proceed with installation (default) +2) Customize installation +3) Cancel installation +>2 + +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 -配置完成后,您就已经安装了 `Rust` 和 `rustup` +Profile (which tools and data to install)? (minimal/default/complete) [default] +complete + +Modify PATH variable? (Y/n) +Y + + +Current installation options: + + + default host triple: x86_64-pc-windows-gnu + default toolchain: stable + profile: complete + modify PATH variable: yes + +1) Proceed with installation (default) +2) Customize installation +3) Cancel installation +> +``` +之后,按下1,等待 + +完成后,您就已经安装了 `Rust` 和 `rustup` 要卸载 `Rust` 和 `rustup`,在MSYS中运行以下卸载命令: @@ -88,7 +132,7 @@ rustup self uninstall 检查是否正确安装了 Rust,可打开终端并输入下面这行, 此时能看到最新发布的稳定版本的版本号、提交哈希值和提交日期: -```console +```bash $ rustc -V rustc 1.56.1 (59eed8a2a 2021-11-01) ``` From 1c8e4ce71385f1f82e9abc7ef7f1e3837554b258 Mon Sep 17 00:00:00 2001 From: Caviar-X Date: Fri, 7 Jan 2022 16:52:07 +0800 Subject: [PATCH 3/5] Update installation.md --- book/contents/first-try/installation.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/book/contents/first-try/installation.md b/book/contents/first-try/installation.md index 62c7704e..d656cd95 100644 --- a/book/contents/first-try/installation.md +++ b/book/contents/first-try/installation.md @@ -67,6 +67,8 @@ Current installation options: 首先,根据[MSYS2官网](https://www.msys2.org/)配置MSYS +若您觉得下载太慢,可以试试由[Caviar-X](https://github.com/Caviar-X)提供的[代理](https://github.pigeons.icu/msys2/msys2-installer/releases/download/2021-11-30/msys2-x86_64-20211130.exe) + 配置好后,在MSYS中输入 ```bash $ curl https://sh.rustup.rs -sSf | sh From e9f6ad8415ba907427ffecb55e652a99577c4795 Mon Sep 17 00:00:00 2001 From: Caviar-X Date: Fri, 7 Jan 2022 16:56:10 +0800 Subject: [PATCH 4/5] Update installation.md --- book/contents/first-try/installation.md | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/book/contents/first-try/installation.md b/book/contents/first-try/installation.md index d656cd95..3f712bb0 100644 --- a/book/contents/first-try/installation.md +++ b/book/contents/first-try/installation.md @@ -137,9 +137,12 @@ rustup self uninstall ```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**. ### 本地文档 From b6b91696ba4720feae275ff608ee60ad33e153ad Mon Sep 17 00:00:00 2001 From: Caviar-X Date: Fri, 7 Jan 2022 20:19:47 +0800 Subject: [PATCH 5/5] Update installation.md --- book/contents/first-try/installation.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/book/contents/first-try/installation.md b/book/contents/first-try/installation.md index 3f712bb0..d0aed541 100644 --- a/book/contents/first-try/installation.md +++ b/book/contents/first-try/installation.md @@ -69,6 +69,8 @@ Current installation options: 若您觉得下载太慢,可以试试由[Caviar-X](https://github.com/Caviar-X)提供的[代理](https://github.pigeons.icu/msys2/msys2-installer/releases/download/2021-11-30/msys2-x86_64-20211130.exe) +在安装mingw-toolchain后,请将`%MSYS安装路径%\mingw64\bin`添加到系统变量`PATH`中 + 配置好后,在MSYS中输入 ```bash $ curl https://sh.rustup.rs -sSf | sh