157文字
1分
編集

Windowsでcargo build実行時にlinkerが見つからないエラーが発生した

#状況

Windows で Rust をインストールして実行したら次のエラーが出た。

shell
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.

#対処法

エラーメッセージにある通り、Visual Studio 2017 以降、または Visual C++オプションをインストールした Build Tools for Visual Studio をインストールする必要がある。

次のコマンドでビルドツールをインストールする。

shell
winget install Microsoft.VisualStudio.2022.BuildTools

Visual Studio Installer を起動して、「C++によるデスクトップ開発」を選択し変更を押す。 インストールの完了を待つ。

編集