Ubuntu 20.04 LTS に Rustをインストール

クリーンインストールしたUbuntu20.04 LTSに Rustコンパイラをインストールする。
Ubuntuは最小インストールで入れたので、普通にやっても色々足りなかったので備忘録。

Rustを持ってくるのに必要。普通は普通に入っている。

$ sudo apt install curl

Rusu の build に必要。普通は普通に入っている。

$ sudo apt-get install gcc

Rustのインストール

$ curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh

PATHを反映させる。一回ログアウトしても良い。再起動でもいい。*1

$ source ~/.profile

バージョンの確認

$ rustup -V
rustup 1.22.1 (b01adbbc3 2020-07-08)

Hello World してみる

$ mkdir rust_test
$ cd rust_test
$ cargo new hello_rust
  Created binary (application) `hello_rust` package
$ cd hello_rust
$ cargo build
   Compiling hello_rust v0.1.0 (/home/ayu/rust_test/hello_rust)
    Finished dev [unoptimized + debuginfo] target(s) in 0.21s
$ target/debug/hello_rust
Hello, world!
$

大丈夫なようです。

*1)Rustの環境変数だけを反映させるなら

$ source $HOME/.cargo/env

の方がいいようですが、かえって面倒くさいので、特に問題なさそうなら.profile一括反映の方が楽かも。

广告
将在 10 秒后关闭
bannerAds