8
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

rustupでRustをインストールして動かす

Last updated at Posted at 2017-01-04

インストールドキュメントをみるとRustをインストールするにはrustupを使うのが推奨されているみたい。rustupはRustのToolchain management toolとのこと。ホスト側のOSのアーキテクチャ用のRust用のツールのインストールをやってくれたり、ツールチェーンのバージョン管理をやってくれるみたい。他のアーキテクチャ向けのツールチェーンを管理する事で、クロスコンパイルとかも簡単にできるようにしてあるっぽい。

rustupを使ってRustをインストールして簡単なアプリケーションを動かすところまでやってみる。

検証環境

vagrant@vagrant:~$ uname -a
Linux vagrant 3.13.0-92-generic #139-Ubuntu SMP Tue Jun 28 20:42:26 UTC 2016 x86_64 x86_64 x86_64 GNU/Linux
vagrant@vagrant:~$ cat /etc/lsb-release
DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=14.04
DISTRIB_CODENAME=trusty
DISTRIB_DESCRIPTION="Ubuntu 14.04.4 LTS"

インストール

インストールドキュメントに従ってインストールしてみる。

$ curl https://sh.rustup.rs -sSf | sh
...
$ source $HOME/.cargo/env
$ which rustc
$ which rustc
/home/vagrant/.cargo/bin/rustc
$ ls ~/.cargo/bin/
cargo      rustc      rustdoc    rust-gdb   rust-lldb  rustup

ユーザ領域にRustの関連バイナリをインストールしてくれた。
簡単!!!

アプリケーションを動かしてみる

$ cargo new test_app --bin
$ cat src/main.rs
fn main() {
    println!("Hello, world!");
}
$ cargo build
$ cargo run
$ cargo run
    Finished debug [unoptimized + debuginfo] target(s) in 0.0 secs
     Running `target/debug/test_app`
Hello, world!

動いた!!!

まとめ

rustupを使うとRustのツールチェーンを簡単に入れる事ができた

8
3
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
8
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?