Category: ‘Rust’

Proxy内でRustをビルドする。

2017年3月16日 Posted by PURGE

最近な言語は、コンパイルで必要なライブラリをGithub等から直接更新するようなものが多い。
そこで、必ずハマるのが、proxyに邪魔されて、ライブラリが取得できないようなこと。

error: failed to load source for a dependency on `rand`
Caused by:
  Unable to update registry https://github.com/rust-lang/crates.io-index
Caused by:
  failed to fetch `https://github.com/rust-lang/crates.io-index`
To learn more, run the command again with --verbose.

Rustもそんな言語のひとつであるが、下記環境での設定方法を記載。
実際は、cargoの設定であるが。

Windowsの場合、Rustをインストールすると、ホームディレクトリに、.cargo というフォルダが存在する。
その中に、下記のファイルを作成し記述する。

C:\Users\myname\.cargo\config

[http]
proxy = "http://user:password@host:port"

設定がOKであれば、レジストリから更新されコンパイルされ実行される。

C:\Rust\main>cargo run
    Updating registry `https://github.com/rust-lang/crates.io-index`
   Compiling main v0.1.0 (file:///C:/Rust/main)
    Finished debug [unoptimized + debuginfo] target(s) in 0.42 secs
     Running `target\debug\main.exe`

なかなか楽しい。

RustでHello World

2017年1月27日 Posted by PURGE

最近、Rustという言語を知った。
ちょっと興味を持ったので、ハローワールドしてみた。

環境
OS:Windows7

下記のページでインストーラを取得してインストール。
https://www.rust-lang.org/en-US/other-installers.html

チュートリアル通りではあるが、下記のファイルを作成しコンパイル。

main.rs

fn main(){
	println!("こんにちは. たぢさん。");
}
c:\work\> rustc main.rs

すると、Window環境なので、main.exe が生成される。

c:\work\> main.exe
こんにちは たぢさん。

楽しそうだ。暇があったら、勉強してみようかと思う。