一般社団法人 全国個人事業主支援協会

COLUMN コラム

Rustの公式で、WSLインストール手順を実施し、HelloWorldプロジェクトを作成

$ curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
$ source $HOME/.cargo/env
$ cargo new hello-rust
$ cd hello-rust/
$ cargo run

cargo run を実行した際に、下記エラーが発生

error: linker `cc` not found
  |
  = note: No such file or directory (os error 2)


error: aborting due to previous error


error: could not compile `hello-rust`.


To learn more, run the command again with --verbose.

CCがないとの事なので、GCCを入れて再実行

$ sudo apt update
$ sudo apt install -y gcc
$ cargo run
    Finished dev [unoptimized + debuginfo] target(s) in 0.37s
     Running `target/debug/hello-rust`
Hello, world!

出来ました

WSLで以下のエラーが発生した場合、WSL2にバージョンを上げることで解消される

warning: Error finalizing incremental compilation session directory

記載時点(2020/04/25)では安定板のWindows10ではWSL2にすることは出来なかったので、WIPに参加し、下記手順を実行
https://docs.microsoft.com/en-us/windows/wsl/wsl2-install

The following two tabs change content below.

WATANABE REN

千葉県在住のエンジニアです。最近はPythonやってます。

この記事をシェアする

  • Twitterでシェア
  • Facebookでシェア
  • LINEでシェア