Trying to solve a Rust exercise for the first time on this (Windows) machine, I am running into the following error.
PS > cargo test
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.
How might I resolve this? I suspect the answer should be included in the Rust installation guide.
As a bonus, I’d like the solution to be minimal in some sense. Installing some 5GB package of tools just to get a linker seems wasteful.
You shouldn’t need to install VS, but just the build tools. However, you may need a (free) MS account to download and install the build tools, and the VS Installer needs to be installed. You might be tempted to delete the installer after installing the build tools, but the build tools get updated fairly frequently, so if you want to keep them up-to-date, you may want to keep the VS installer around for that.
Then you can use vscode. Not sure about other IDEs.
Here’s the link for downloading just the build tools, but I think it will also install the VS installer (not VS), IIRC.
vs_buildtools.exe / “Visual Studio Installer”, but I couldn’t figure out which (minimal) component I need.
If no-one knows this in a few days I’ll go on the long trial-and-error hunt myself and report back.
I originally ran Rust with just build tools but I eventually installed VS for C++ and C#, so not sure now what the minimum was, but I’ll give it a try to describe what I think it is:
In the installer “Individual Components” tab under the Compilers, build tools, and runtimes section, I have checked
C++ 2019 redistributable update
C++ CMake tools for Windows
MSVC v142 - VS 2019 C++ x64/x86 build tools (latest)
Under the Debugging and testing section I have checked
Testing tools core features - Build Tools
Under the Development activities section I have checked
C++ Build Tools core features
C++ core features
Under SDKs, libraries, and frameworks I have checked
Windows 10 SDK (10.0.18362.0)
Windows 11 SDK (10.0.22000.0)
Windows Universal C Runtime
I suspect none of the SDK stuff is needed, along with the testing tools, but I could be wrong.
When I first bring up VS Installer it shows I have Visual Studio Build Tools installed for both 2019 (v 16.11.23) and 2017 (15.9.51). Not sure if the 2017 is still needed, but I think it was when I first started using Rust a few years ago.