Resolving “`link.exe` not found” Error in Rust

If you’ve encountered the “link.exe not found" error while running “cargo install cargo-generate" , here’s how you can fix it.

TL;DR

Installing “Build Tools for Visual Studio 2022" under “Desktop development with C++" resolved the error.

The Issue

You decided to explore Rust for controlling a Raspberry Pi Pico, and when you ran “cargo install cargo-generate," you encountered the “linker 'link.exe’ not found" error midway.

Solution

After some investigation, I found a solution on a website. However, the instructions were for Visual Studio 2019, and the names and items differed. So, here’s a record of what worked for me.

Download Build Tools for Visual Studio 2022

Visit the Visual Studio download site.
Scroll down a bit and find “Build Tools for Visual Studio 2022" under “Tools for Visual Studio 2022."
Download it from https://visualstudio.microsoft.com/ja/downloads/

Installation

  • Run vs_BuildTools.exe.
  • Check the box for “Desktop development with C++."
  • Proceed with the installation.

Completion and Success

Once the installation was complete, the process that was previously failing now worked without any issues.