Debian 11.2にRust言語をインストールする

環境情報
# cat /etc/debian_version
11.2

Rustのインストールの方法

1.Rust をインストールます

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

2.Rustバージョンを確認します

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
# rustc --version
rustc 1.48.0
# rustc --version rustc 1.48.0
# rustc --version
rustc 1.48.0

3.テストプログラムを作成します
# nano test.rs
下記の内容を追記します

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
fn main() {
println!("study Rust become smart");
}
fn main() { println!("study Rust become smart"); }
fn main() {
    println!("study Rust become smart");
}

4.rustcでファイルを実行します

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
ファイルをコンパイルします
# rustc test.rs
コンパイルしたファイルを実行します
# ./test
study Rust become smart
ファイルをコンパイルします # rustc test.rs コンパイルしたファイルを実行します # ./test study Rust become smart
ファイルをコンパイルします
# rustc test.rs
コンパイルしたファイルを実行します
# ./test
study Rust become smart

5.cargoでファイルを実行します

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
cargoバージョンを確認します
# cargo --version
cargo 1.46.0
# cargo new sample --bin
Created binary (application) `sample` package
# cd sample
# cargo build
Compiling sample v0.1.0 (/root/sample)
Finished dev [unoptimized + debuginfo] target(s) in 0.37s
# cargo run
Finished dev [unoptimized + debuginfo] target(s) in 0.00s
Running `target/debug/sample`
Hello, world!
cargoバージョンを確認します # cargo --version cargo 1.46.0 # cargo new sample --bin Created binary (application) `sample` package # cd sample # cargo build Compiling sample v0.1.0 (/root/sample) Finished dev [unoptimized + debuginfo] target(s) in 0.37s # cargo run Finished dev [unoptimized + debuginfo] target(s) in 0.00s Running `target/debug/sample` Hello, world!
cargoバージョンを確認します
#  cargo --version
cargo 1.46.0
# cargo new sample --bin
     Created binary (application) `sample` package
# cd sample
# cargo build
   Compiling sample v0.1.0 (/root/sample)
    Finished dev [unoptimized + debuginfo] target(s) in 0.37s
# cargo run
    Finished dev [unoptimized + debuginfo] target(s) in 0.00s
     Running `target/debug/sample`
Hello, world!

 

Debian 11

Posted by arkgame