wslでrust

# 概要
wslでrustやってみた。

# 環境
windows11
wsl1
ubuntu22.04

# インストール手順

```
~$ sudo apt install rust-all
[sudo] password for ore:
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
The following packages were automatically installed and are no longer required:
  berkeley-abc ghdl-mcode
Use 'sudo apt autoremove' to remove them.
The following additional packages will be installed:
  cargo gdb libbabeltrace1 libboost-regex1.74.0 libc6-dbg libdebuginfod-common libdebuginfod1 libipt2
  libsource-highlight-common libsource-highlight4v5 libssh2-1 libstd-rust-1.75 libstd-rust-dev rust-clippy rust-gdb
  rustc rustfmt
Suggested packages:
  cargo-doc gdb-doc gdbserver rust-doc rust-src llvm-17 lld-17 clang-17
The following NEW packages will be installed:
  cargo gdb libbabeltrace1 libboost-regex1.74.0 libc6-dbg libdebuginfod-common libdebuginfod1 libipt2
  libsource-highlight-common libsource-highlight4v5 libssh2-1 libstd-rust-1.75 libstd-rust-dev rust-all rust-clippy
  rust-gdb rustc rustfmt
0 upgraded, 18 newly installed, 0 to remove and 111 not upgraded.
Need to get 122 MB of archives.
After this operation, 446 MB of additional disk space will be used.
Do you want to continue? [Y/n] y
Get:1 http://archive.ubuntu.com/ubuntu jammy/main amd64 libdebuginfod-common all 0.186-1build1 [7878 B]
Get:2 http://archive.ubuntu.com/ubuntu jammy/main amd64 libbabeltrace1 amd64 1.5.8-2build1 [160 kB]
Get:3 http://archive.ubuntu.com/ubuntu jammy/main amd64 libdebuginfod1 amd64 0.186-1build1 [12.7 kB]
Get:4 http://archive.ubuntu.com/ubuntu jammy/main amd64 libipt2 amd64 2.0.5-1 [46.4 kB]
Get:5 http://archive.ubuntu.com/ubuntu jammy/main amd64 libsource-highlight-common all 3.1.9-4.1build2 [64.5 kB]
Get:6 http://archive.ubuntu.com/ubuntu jammy/main amd64 libboost-regex1.74.0 amd64 1.74.0-14ubuntu3 [511 kB]
Get:7 http://archive.ubuntu.com/ubuntu jammy/main amd64 libsource-highlight4v5 amd64 3.1.9-4.1build2 [207 kB]
Get:8 http://archive.ubuntu.com/ubuntu jammy-updates/main amd64 gdb amd64 12.1-0ubuntu1~22.04.2 [3920 kB]
Get:9 http://archive.ubuntu.com/ubuntu jammy/universe amd64 libssh2-1 amd64 1.10.0-3 [109 kB]
Get:10 http://archive.ubuntu.com/ubuntu jammy-updates/main amd64 libstd-rust-1.75 amd64 1.75.0+dfsg0ubuntu1~bpo0-0ubuntu0.22.04 [46.3 MB]
Get:11 http://archive.ubuntu.com/ubuntu jammy-updates/main amd64 libstd-rust-dev amd64 1.75.0+dfsg0ubuntu1~bpo0-0ubuntu0.22.04 [41.6 MB]
Get:12 http://archive.ubuntu.com/ubuntu jammy-updates/main amd64 rustc amd64 1.75.0+dfsg0ubuntu1~bpo0-0ubuntu0.22.04 [3404 kB]
Get:13 http://archive.ubuntu.com/ubuntu jammy-updates/universe amd64 rustfmt amd64 1.75.0+dfsg0ubuntu1~bpo0-0ubuntu0.22.04 [2204 kB]
Get:14 http://archive.ubuntu.com/ubuntu jammy-updates/universe amd64 rust-clippy amd64 1.75.0+dfsg0ubuntu1~bpo0-0ubuntu0.22.04 [2695 kB]
Get:15 http://archive.ubuntu.com/ubuntu jammy-updates/universe amd64 rust-gdb all 1.75.0+dfsg0ubuntu1~bpo0-0ubuntu0.22.04 [239 kB]
Get:16 http://archive.ubuntu.com/ubuntu jammy-updates/universe amd64 cargo amd64 1.75.0+dfsg0ubuntu1~bpo0-0ubuntu0.22.04 [6700 kB]
Get:17 http://archive.ubuntu.com/ubuntu jammy-updates/universe amd64 rust-all all 1.75.0+dfsg0ubuntu1~bpo0-0ubuntu0.22.04 [233 kB]
Get:18 http://archive.ubuntu.com/ubuntu jammy-updates/main amd64 libc6-dbg amd64 2.35-0ubuntu3.8 [13.8 MB]
Fetched 122 MB in 20s (6144 kB/s)
Preconfiguring packages ...
Selecting previously unselected package libdebuginfod-common.
(Reading database ... 208965 files and directories currently installed.)
Preparing to unpack .../00-libdebuginfod-common_0.186-1build1_all.deb ...
Unpacking libdebuginfod-common (0.186-1build1) ...
Selecting previously unselected package libbabeltrace1:amd64.
Preparing to unpack .../01-libbabeltrace1_1.5.8-2build1_amd64.deb ...
Unpacking libbabeltrace1:amd64 (1.5.8-2build1) ...
Selecting previously unselected package libdebuginfod1:amd64.
Preparing to unpack .../02-libdebuginfod1_0.186-1build1_amd64.deb ...
Unpacking libdebuginfod1:amd64 (0.186-1build1) ...
Selecting previously unselected package libipt2.
Preparing to unpack .../03-libipt2_2.0.5-1_amd64.deb ...
Unpacking libipt2 (2.0.5-1) ...
Selecting previously unselected package libsource-highlight-common.
Preparing to unpack .../04-libsource-highlight-common_3.1.9-4.1build2_all.deb ...
Unpacking libsource-highlight-common (3.1.9-4.1build2) ...
Selecting previously unselected package libboost-regex1.74.0:amd64.
Preparing to unpack .../05-libboost-regex1.74.0_1.74.0-14ubuntu3_amd64.deb ...
Unpacking libboost-regex1.74.0:amd64 (1.74.0-14ubuntu3) ...
Selecting previously unselected package libsource-highlight4v5.
Preparing to unpack .../06-libsource-highlight4v5_3.1.9-4.1build2_amd64.deb ...
Unpacking libsource-highlight4v5 (3.1.9-4.1build2) ...
Selecting previously unselected package gdb.
Preparing to unpack .../07-gdb_12.1-0ubuntu1~22.04.2_amd64.deb ...
Unpacking gdb (12.1-0ubuntu1~22.04.2) ...
Selecting previously unselected package libssh2-1:amd64.
Preparing to unpack .../08-libssh2-1_1.10.0-3_amd64.deb ...
Unpacking libssh2-1:amd64 (1.10.0-3) ...
Selecting previously unselected package libstd-rust-1.75:amd64.
Preparing to unpack .../09-libstd-rust-1.75_1.75.0+dfsg0ubuntu1~bpo0-0ubuntu0.22.04_amd64.deb ...
Unpacking libstd-rust-1.75:amd64 (1.75.0+dfsg0ubuntu1~bpo0-0ubuntu0.22.04) ...
Selecting previously unselected package libstd-rust-dev:amd64.
Preparing to unpack .../10-libstd-rust-dev_1.75.0+dfsg0ubuntu1~bpo0-0ubuntu0.22.04_amd64.deb ...
Unpacking libstd-rust-dev:amd64 (1.75.0+dfsg0ubuntu1~bpo0-0ubuntu0.22.04) ...
Selecting previously unselected package rustc.
Preparing to unpack .../11-rustc_1.75.0+dfsg0ubuntu1~bpo0-0ubuntu0.22.04_amd64.deb ...
Unpacking rustc (1.75.0+dfsg0ubuntu1~bpo0-0ubuntu0.22.04) ...
Selecting previously unselected package rustfmt.
Preparing to unpack .../12-rustfmt_1.75.0+dfsg0ubuntu1~bpo0-0ubuntu0.22.04_amd64.deb ...
Unpacking rustfmt (1.75.0+dfsg0ubuntu1~bpo0-0ubuntu0.22.04) ...
Selecting previously unselected package rust-clippy.
Preparing to unpack .../13-rust-clippy_1.75.0+dfsg0ubuntu1~bpo0-0ubuntu0.22.04_amd64.deb ...
Unpacking rust-clippy (1.75.0+dfsg0ubuntu1~bpo0-0ubuntu0.22.04) ...
Selecting previously unselected package rust-gdb.
Preparing to unpack .../14-rust-gdb_1.75.0+dfsg0ubuntu1~bpo0-0ubuntu0.22.04_all.deb ...
Unpacking rust-gdb (1.75.0+dfsg0ubuntu1~bpo0-0ubuntu0.22.04) ...
Selecting previously unselected package cargo.
Preparing to unpack .../15-cargo_1.75.0+dfsg0ubuntu1~bpo0-0ubuntu0.22.04_amd64.deb ...
Unpacking cargo (1.75.0+dfsg0ubuntu1~bpo0-0ubuntu0.22.04) ...
Selecting previously unselected package rust-all.
Preparing to unpack .../16-rust-all_1.75.0+dfsg0ubuntu1~bpo0-0ubuntu0.22.04_all.deb ...
Unpacking rust-all (1.75.0+dfsg0ubuntu1~bpo0-0ubuntu0.22.04) ...
Selecting previously unselected package libc6-dbg:amd64.
Preparing to unpack .../17-libc6-dbg_2.35-0ubuntu3.8_amd64.deb ...
Unpacking libc6-dbg:amd64 (2.35-0ubuntu3.8) ...
Setting up libdebuginfod-common (0.186-1build1) ...

Creating config file /etc/profile.d/debuginfod.sh with new version

Creating config file /etc/profile.d/debuginfod.csh with new version
Setting up libdebuginfod1:amd64 (0.186-1build1) ...
Setting up libstd-rust-1.75:amd64 (1.75.0+dfsg0ubuntu1~bpo0-0ubuntu0.22.04) ...
Setting up libsource-highlight-common (3.1.9-4.1build2) ...
Setting up libc6-dbg:amd64 (2.35-0ubuntu3.8) ...
Setting up libstd-rust-dev:amd64 (1.75.0+dfsg0ubuntu1~bpo0-0ubuntu0.22.04) ...
Setting up libboost-regex1.74.0:amd64 (1.74.0-14ubuntu3) ...
Setting up libipt2 (2.0.5-1) ...
Setting up libbabeltrace1:amd64 (1.5.8-2build1) ...
Setting up rustc (1.75.0+dfsg0ubuntu1~bpo0-0ubuntu0.22.04) ...
Setting up libssh2-1:amd64 (1.10.0-3) ...
Setting up rust-clippy (1.75.0+dfsg0ubuntu1~bpo0-0ubuntu0.22.04) ...
Setting up rustfmt (1.75.0+dfsg0ubuntu1~bpo0-0ubuntu0.22.04) ...
Setting up libsource-highlight4v5 (3.1.9-4.1build2) ...
Setting up cargo (1.75.0+dfsg0ubuntu1~bpo0-0ubuntu0.22.04) ...
Setting up gdb (12.1-0ubuntu1~22.04.2) ...
Setting up rust-gdb (1.75.0+dfsg0ubuntu1~bpo0-0ubuntu0.22.04) ...
Setting up rust-all (1.75.0+dfsg0ubuntu1~bpo0-0ubuntu0.22.04) ...
Processing triggers for man-db (2.10.2-1) ...
Processing triggers for libc-bin (2.35-0ubuntu3.4) ...




```

# 確認

```
$ rustc --version
rustc 1.75.0 (82e1608df 2023-12-21) (built from a source tarball)
~$ cargo --version
cargo 1.75.0
~$ rustup --version
rustup: command not found

~$ mkdir rust
~$ cd rust
~/rust$ echo "s" > hello.rs
~/rust$ ls
hello.rs
~/rust$ explorer.exe .
~/rust$ rustc hello.rs
~/rust$ ls
hello  hello.rs
~/rust$ ./hello
Hello, world!

~/rust$ cargo new hello0
     Created binary (application) `hello0` package
~/rust$ cd hello0
~/rust/hello0$ cargo build
   Compiling hello0 v0.1.0 (/home/ore/rust/hello0)
    Finished dev [unoptimized + debuginfo] target(s) in 2.87s
~/rust/hello0$ cargo run
    Finished dev [unoptimized + debuginfo] target(s) in 0.09s
     Running `target/debug/hello0`
Hello, world!
~/rust/hello0$

```



以上