「Windows11」 Rustをインストールする方法

環境

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
エディション Windows 11 Pro
バージョン 21H2
システムの種類 64 ビット オペレーティング システム、x64 ベース プロセッサ
エディション Windows 11 Pro バージョン 21H2 システムの種類 64 ビット オペレーティング システム、x64 ベース プロセッサ
エディション Windows 11 Pro
バージョン 21H2
システムの種類 64 ビット オペレーティング システム、x64 ベース プロセッサ

操作方法
1.下記サイトからRustをダウンロードします。
https://www.rust-lang.org/tools/install
64bit「rustup-init.exe」をダウンロードします。

2.ダウンロードした「rustup-init.exe」をダブルクリックして実行します。

3.コマンドプロンプトが起動します。
「1」と入力してENTERキーを押下します

4.Visual Studio のインストーラーが起動します。

5.各種ツールをインストールします。「default」の「1」を選択してます。

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
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
>1
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 >1
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
>1

6.インストールが完了したのでENTERキーを押下します。

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
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.
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.
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.

7.Rust環境変数の設定

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
 1)Windowsキーを押下します
 2)「検索するには、ここに入力します」欄に「env」と入力します。
 3)システム環境変数の編集を選択します。
 4)システムのプロパティ画面が表示されます。
 5)「環境変数(N)」->「システム環境変数(S)」->「Path」->「編集(I)」をクリックします。
 6) 環境変数名の編集画面が表示されます。
   「新規(N)」をクリックします。
   「%USERPROFILE%.cargo\bin」を入力して「OK」を押下します。
 1)Windowsキーを押下します  2)「検索するには、ここに入力します」欄に「env」と入力します。  3)システム環境変数の編集を選択します。  4)システムのプロパティ画面が表示されます。  5)「環境変数(N)」->「システム環境変数(S)」->「Path」->「編集(I)」をクリックします。  6) 環境変数名の編集画面が表示されます。    「新規(N)」をクリックします。    「%USERPROFILE%.cargo\bin」を入力して「OK」を押下します。
 1)Windowsキーを押下します
 2)「検索するには、ここに入力します」欄に「env」と入力します。
 3)システム環境変数の編集を選択します。
 4)システムのプロパティ画面が表示されます。
 5)「環境変数(N)」->「システム環境変数(S)」->「Path」->「編集(I)」をクリックします。
 6) 環境変数名の編集画面が表示されます。
   「新規(N)」をクリックします。
   「%USERPROFILE%.cargo\bin」を入力して「OK」を押下します。

8.動作確認
test.rsを作成します

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
fn main() {
println!("Hello World Study Rust")
}
fn main() { println!("Hello World Study Rust") }
fn main() {
    println!("Hello World Study Rust")
}

ファイルをコンパイルします。
C:\study\rust>rustc test.rs

コンパイルしたファイルを実行します。

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
C:\study\rust>.\test.exe
Hello World Study Rust
C:\study\rust>.\test.exe Hello World Study Rust
C:\study\rust>.\test.exe
Hello World Study Rust

 

Windows11

Posted by arkgame