【Rust】使用 rust-init 安裝 GNU 版


環境

  • Windows 10

下載 rust-init

進入官網的下載頁面:https://www.rust-lang.org/tools/install
根據 32 還是 64 位系統選擇下載不同的 exe 文件,下載完成后雙擊運行。

下載 rust-init

安裝 Rust

前置條件說明

默認情況,Rust 依賴 C++ build tools,所以有一個提醒,並且提供了安裝的方式。
最后也說明了,如果基於 GNU ABI 就可以不安裝,並且詢問是否繼續,輸入 y 回車繼續。

Rust Visual C++ prerequisites

Rust requires the Microsoft C++ build tools for Visual Studio 2013 or later, but they don't seem to be installed.

The easiest way to acquire the build tools is by installing Microsoft Visual C++ Build Tools 2019 which provides just the Visual C++ build tools:

  https://visualstudio.microsoft.com/visual-cpp-build-tools/

Please ensure the Windows 10 SDK and the English language pack components are included when installing the Visual C++ Build Tools.

Alternately, you can install Visual Studio 2019, Visual Studio 2017, Visual Studio 2015, or Visual Studio 2013 and during install select the "C++ tools":

  https://visualstudio.microsoft.com/downloads/

Install the C++ build tools before proceeding.

If you will be targeting the GNU ABI or otherwise know what you are doing then it is fine to continue installation without the build tools, but otherwise, install the C++ build tools before proceeding.

Continue? (y/N) y

選擇自定義安裝

安裝繼續時,先是說明了會安裝哪些工具,並且會安裝到哪個目錄,可以通過哪些方式修改,這里都直接默認。
在最后,有三個選項,由於需要安裝基於 GNU 的方式,所以選擇 2,自定義安裝。

Welcome to Rust!

This will download and install the official compiler for the Rust programming language, and its package manager, Cargo.

Rustup metadata and toolchains will be installed into the Rustup home directory, located at:

  C:\Users\jiangbo\.rustup

This can be modified with the RUSTUP_HOME environment variable.

The Cargo home directory located at:

  C:\Users\jiangbo\.cargo

This can be modified with the CARGO_HOME environment variable.

The cargo, rustc, rustup and other commands will be added to Cargo's bin directory, located at:

  C:\Users\jiangbo\.cargo\bin

This path will then be added to your PATH environment variable by modifying the HKEY_CURRENT_USER/Environment/PATH registry key.

You can uninstall at any time with rustup self uninstall and these changes will be reverted.

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

自定義安裝配置

x86_64-pc-windows-msvc 修改為 x86_64-pc-windows-gnu,其他的可以直接選擇默認。
最后會確認安裝信息,如果沒有問題,直接回車安裝,這時會到網上下載文件,要保證網絡正常。

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]


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
>

查看安裝過程

info: profile set to 'complete'
info: setting default host triple to x86_64-pc-windows-gnu
info: syncing channel updates for 'stable-x86_64-pc-windows-gnu'
info: latest update on 2021-07-29, rust version 1.54.0 (a178d0322 2021-07-26)
warning: Force-skipping unavailable component 'miri-x86_64-pc-windows-gnu'
warning: Force-skipping unavailable component 'rust-analyzer-preview-x86_64-pc-windows-gnu'
info: downloading component 'cargo'
  6.7 MiB /   6.7 MiB (100 %)   5.5 MiB/s in  1s ETA:  0s
info: downloading component 'clippy'
info: downloading component 'llvm-tools-preview'
 69.6 MiB /  69.6 MiB (100 %)   5.5 MiB/s in 16s ETA:  0s
info: downloading component 'rls'
 11.1 MiB /  11.1 MiB (100 %)   3.6 MiB/s in  4s ETA:  0s
info: downloading component 'rust-analysis'
  2.6 MiB /   2.6 MiB (100 %)   1.9 MiB/s in  2s ETA:  0s
info: downloading component 'rust-docs'
 16.8 MiB /  16.8 MiB (100 %)   5.5 MiB/s in  3s ETA:  0s
info: downloading component 'rust-mingw'
info: downloading component 'rust-src'
info: downloading component 'rust-std'
 28.4 MiB /  28.4 MiB (100 %)   5.5 MiB/s in  5s ETA:  0s
info: downloading component 'rustc'
145.1 MiB / 145.1 MiB (100 %)   5.5 MiB/s in 28s ETA:  0s
info: downloading component 'rustfmt'
  6.0 MiB /   6.0 MiB (100 %)   5.5 MiB/s in  1s ETA:  0s
info: installing component 'cargo'
info: installing component 'clippy'
info: installing component 'llvm-tools-preview'
 69.6 MiB /  69.6 MiB (100 %)  10.4 MiB/s in  6s ETA:  0s
info: installing component 'rls'
 11.1 MiB /  11.1 MiB (100 %)  10.8 MiB/s in  1s ETA:  0s
info: installing component 'rust-analysis'
info: installing component 'rust-docs'
 16.8 MiB /  16.8 MiB (100 %)   1.7 MiB/s in  9s ETA:  0s
info: installing component 'rust-mingw'
info: installing component 'rust-src'
info: installing component 'rust-std'
 28.4 MiB /  28.4 MiB (100 %)  10.7 MiB/s in  3s ETA:  0s
info: installing component 'rustc'
145.1 MiB / 145.1 MiB (100 %)   9.7 MiB/s in 14s ETA:  0s
info: installing component 'rustfmt'
info: default toolchain set to 'stable-x86_64-pc-windows-gnu'

  stable-x86_64-pc-windows-gnu installed - (timeout reading rustc version)

Rust is installed now. Great!

To get started you may need to restart your current shell.
This would reload its PATH environment variable to include
Cargo's bin directory (%USERPROFILE%\.cargo\bin).

Press the Enter key to continue.

驗證安裝成功

使用命令 rustc --version 命令驗證是否安裝成功。

C:\Users\jiangbo>rustc --version
rustc 1.54.0 (a178d0322 2021-07-26)

附錄


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM