Ubuntu 22.04 LTSにプログラム言語Rustをインストールする

環境
Ubuntu 22.04 LTS

1.gccをインストールします

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
# sudo apt install -y gcc
# sudo apt install -y gcc
# sudo apt install -y gcc

2.curlコマンドでRustをインストールします

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
# curl https://sh.rustup.rs -sSf | sh
Current installation options:
default host triple: x86_64-unknown-linux-gnu
default toolchain: stable (default)
profile: default
modify PATH variable: yes
1) Proceed with installation (default)
2) Customize installation
3) Cancel installation
>1 #「1」を選択します
# curl https://sh.rustup.rs -sSf | sh Current installation options: default host triple: x86_64-unknown-linux-gnu default toolchain: stable (default) profile: default modify PATH variable: yes 1) Proceed with installation (default) 2) Customize installation 3) Cancel installation >1 #「1」を選択します
# curl https://sh.rustup.rs -sSf | sh

Current installation options:


default host triple: x86_64-unknown-linux-gnu
default toolchain: stable (default)
profile: default
modify PATH variable: yes

1) Proceed with installation (default)
2) Customize installation
3) Cancel installation
>1 #「1」を選択します

3.環境パスを設定します

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
# source $HOME/.cargo/env
# source $HOME/.cargo/env
# source $HOME/.cargo/env

バージョンを確認します

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
# rustc --version
rustc 1.60.0 (7737e0b5c 2022-04-04)
# rustc --version rustc 1.60.0 (7737e0b5c 2022-04-04)
# rustc --version
rustc 1.60.0 (7737e0b5c 2022-04-04)

 

4.動作確認
# nano hello.rs
以下の内容を編集します

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
fn main() {
println!("Hello, world study skill");
}
fn main() { println!("Hello, world study skill"); }
fn main() {
println!("Hello, world study skill");
}

ファイルをコンパイルします
# rustc hello.rs
ファイルを実行します
# ./hello
Hello, world study skill

Ubuntu 22.04

Posted by arkgame