S-JIS[2024-09-16] 変更履歴

Rustインストール方法

Rustのインストール方法のメモ。


Windowsへのインストール

  1. Visual Studio C++ Build toolsをインストールする。(Visual Studio Code(VS Code)とは別物)
    1. Microsoft C++ Build ToolsからBuild Tools(vs_BuildTools.exe)をダウンロードする。
    2. vs_BuildTools.exeを実行する。
      1. 「C++によるデスクトップ開発」にチェックを入れる。(MSVCのlink.exeが必要な為)
      2. インストール作業を続行する。
  2. Rustをインストールする。
    1. Rust をインストールからインストーラー(rustup-init.exe)をダウンロードする。
    2. rustup-init.exeを実行する。
      1. コンソールが開く。適宜yとかを押す。
      2. 最後にEnterを押して完了。
        %USERPROFILE%\.cargo\bin\にインストールされ、パスが通っている。
    3. 動作確認
      1. コマンドプロンプトでコマンドを実行する。
        > cargo --version
        cargo 1.81.0 (2dbb1af80 2024-08-20)

Visual Studio C++ Build toolsがインストールされていないと、実行時に以下のようなエラーが出る。

> cargo run
   Compiling rust-example1 v0.1.0 (D:\example\rust\rust-example1)
error: linker `link.exe` not found
  |
  = note: program not found

note: the msvc targets depend on the msvc linker but `link.exe` was not found

note: please ensure that Visual Studio 2017 or later, or Build Tools for Visual Studio were installed with the Visual C++ option.

note: VS Code is a different product, and is not sufficient.

error: could not compile `rust-example1` (bin "rust-example1") due to 1 previous error

Rustへ戻る / 技術メモへ戻る
メールの送信先:ひしだま