そのまんまなタイトルですが、備忘録のために解決方法を記載しておきます。
Windows11でRustの開発中、cargo buildしたらこんな感じでエラーが出ました。
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.
wingetコマンドでビルドツールをインストールしてあげましょう。
winget install Microsoft.VisualStudio.2022.BuildTools
これが終わったら、Visual Studio Installer
を起動します。
![](/img/%e3%82%b9%e3%82%af%e3%83%aa%e3%83%bc%e3%83%b3%e3%82%b7%e3%83%a7%e3%83%83%e3%83%88%202023-10-01%20221646.png)
インストール済みのところに先ほどインストールしたビルドツールが表示されています。
ここの変更を押します。
![](/img/%e3%82%b9%e3%82%af%e3%83%aa%e3%83%bc%e3%83%b3%e3%82%b7%e3%83%a7%e3%83%83%e3%83%88%202023-10-01%20221925.png)
「C++によるデスクトップ開発」を選択して、変更をクリックします。
![](/img/%e3%82%b9%e3%82%af%e3%83%aa%e3%83%bc%e3%83%b3%e3%82%b7%e3%83%a7%e3%83%83%e3%83%88%202023-10-01%20221955.png)
これでインストールが開始されます!
インストールが完了したら再起動して、再度cargo build
を走らせれば、このエラーは消えます。