LoginSignup
17
7

More than 3 years have passed since last update.

【メモ】Raspberry Pi でも Rust と Cargo

Last updated at Posted at 2020-03-19

個人用のホームページを作成しました。今後は、そちらの方に整理していきたいと思いますので、よろしくお願いします。

1. Rust のインストール

$ curl https://sh.rustup.rs -sSf | sh

Current installation options: では、1 を選択します。

Current installation options:


   default host triple: armv7-unknown-linux-gnueabihf
     default toolchain: stable
               profile: default
  modify PATH variable: yes

1) Proceed with installation (default)
2) Customize installation
3) Cancel installation
>1

.profileにPATHが追加されるので、ログインし直します。

export PATH="$HOME/.cargo/bin:$PATH"

再度ログインすると rustccargo を実行できます。

$ rustc --version
rustc 1.41.1 (f3e1a954d 2020-02-24)
$ cargo --version
cargo 1.41.0 (626f0f40e 2019-12-03)

2. libssl-dev、pkg-config のインストール

Raspbian では (JetsonNano の Ubuntu 18.04 でも同じでした)、libssl-dev がインストールされていないようなので追加しておきます。

$ sudo apt install -y libssl-dev

libssl-dev がインストールされていない場合、例えば cargo install cargo-edit を実行すると openssl-sys v0.9.54 のコンパイルでエラーが発生します。

error: failed to run custom build command for `openssl-sys v0.9.54`

Caused by:
  process didn't exit successfully: `/tmp/cargo-installbbspY5/release/build/openssl-sys-fdd93143b81b5895/build-script-main` (exit code: 101)

Ubuntu の場合 pkg-config がインストールされていないようなので追加しておきます。

$ sudo apt install -y pkg-config

3. cargo-edit のインストール

$ cargo install cargo-edit

cargo add などのコマンドが使えるようになります。

4. cargo make のインストール

cargo-make をクローンしてインストールします。

$ git clone https://github.com/sagiegurari/cargo-make.git
$ cd cargo-make
$ cargo install --force cargo-make

5. rust を最新版に更新

$ rustup update
17
7
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
17
7