Why is MSVC not installing or being recognized by Rust? - rust

I've tried this repeatedly and still can't figure out where I'm going wrong.
I installed Rust from the official website (version 1.44.1), and I can run rustc --version and get the right result. I can create a new project, but when I run cargo test or cargo build, I get errors.
Compiling hello-rust v0.1.0 (C:\Projects\rust-test\hello-rust)
error: linking with `link.exe` failed: exit code: 1
|
= note: "link.exe" "/NOLOGO" "/NXCOMPAT" "/LIBPATH:C:\\Users\\Jaden\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\x86_64-pc-windows-msvc\\lib" "C:\\Projects\\rust-test\\hello-rust\\target\\debug\\deps\\hello_rust-3bd7255de8fc516c.2475ppgeya7982p6.rcgu.o" "C:\\Projects\\rust-test\\hello-rust\\target\\debug\\deps\\hello_rust-3bd7255de8fc516c.2k8om5gztlm4khis.rcgu.o" "C:\\Projects\\rust-test\\hello-rust\\target\\debug\\deps\\hello_rust-3bd7255de8fc516c.2npazqbfnne9a4sz.rcgu.o" "C:\\Projects\\rust-test\\hello-rust\\target\\debug\\deps\\hello_rust-3bd7255de8fc516c.31mw3i7sxv4jy5mf.rcgu.o" "C:\\Projects\\rust-test\\hello-rust\\target\\debug\\deps\\hello_rust-3bd7255de8fc516c.39lo872ze2g8kjy6.rcgu.o" "/OUT:C:\\Projects\\rust-test\\hello-rust\\target\\debug\\deps\\hello_rust-3bd7255de8fc516c.exe" "C:\\Projects\\rust-test\\hello-rust\\target\\debug\\deps\\hello_rust-3bd7255de8fc516c.3pzk8mfjqu22abeg.rcgu.o" "/OPT:REF,NOICF" "/DEBUG" "/NATVIS:C:\\Users\\Jaden\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\etc\\intrinsic.natvis" "/NATVIS:C:\\Users\\Jaden\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\etc\\liballoc.natvis" "/NATVIS:C:\\Users\\Jaden\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\etc\\libcore.natvis" "/NATVIS:C:\\Users\\Jaden\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\etc\\libstd.natvis" "/LIBPATH:C:\\Projects\\rust-test\\hello-rust\\target\\debug\\deps" "/LIBPATH:C:\\Users\\Jaden\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\x86_64-pc-windows-msvc\\lib" "C:\\Users\\Jaden\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\x86_64-pc-windows-msvc\\lib\\libtest-ce9bcda9bff89d22.rlib" "C:\\Users\\Jaden\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\x86_64-pc-windows-msvc\\lib\\libterm-5685a6e382a0344d.rlib" "C:\\Users\\Jaden\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\x86_64-pc-windows-msvc\\lib\\libgetopts-9672beb79727d086.rlib" "C:\\Users\\Jaden\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\x86_64-pc-windows-msvc\\lib\\libunicode_width-0b6119489f498de7.rlib" "C:\\Users\\Jaden\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\x86_64-pc-windows-msvc\\lib\\librustc_std_workspace_std-f43d3b6a5d7adb85.rlib" "C:\\Users\\Jaden\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\x86_64-pc-windows-msvc\\lib\\libstd-13b0a7dd239e134e.rlib" "C:\\Users\\Jaden\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\x86_64-pc-windows-msvc\\lib\\libpanic_unwind-c6983deeb3795666.rlib" "C:\\Users\\Jaden\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\x86_64-pc-windows-msvc\\lib\\libhashbrown-fb1f6de11ac9d69b.rlib" "C:\\Users\\Jaden\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\x86_64-pc-windows-msvc\\lib\\librustc_std_workspace_alloc-09135599e2aa779b.rlib" "C:\\Users\\Jaden\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\x86_64-pc-windows-msvc\\lib\\libbacktrace-4aec9f98c25f9f5d.rlib" "C:\\Users\\Jaden\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\x86_64-pc-windows-msvc\\lib\\librustc_demangle-29671087b5d92459.rlib" "C:\\Users\\Jaden\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\x86_64-pc-windows-msvc\\lib\\libunwind-7c5d84958fafcb64.rlib" "C:\\Users\\Jaden\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\x86_64-pc-windows-msvc\\lib\\libcfg_if-c820fe24a63d105a.rlib" "C:\\Users\\Jaden\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\x86_64-pc-windows-msvc\\lib\\liblibc-eab51dcd5481cddb.rlib" "C:\\Users\\Jaden\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\x86_64-pc-windows-msvc\\lib\\liballoc-da92c312ae6fecdd.rlib" "C:\\Users\\Jaden\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\x86_64-pc-windows-msvc\\lib\\librustc_std_workspace_core-693c88df9572eb34.rlib" "C:\\Users\\Jaden\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\x86_64-pc-windows-msvc\\lib\\libcore-b5aae910499df009.rlib" "C:\\Users\\Jaden\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\x86_64-pc-windows-msvc\\lib\\libcompiler_builtins-9a7454af4f639d0b.rlib" "kernel32.lib" "advapi32.lib" "ws2_32.lib" "userenv.lib" "msvcrt.lib"
= note: /usr/bin/link: extra operand ‘/LIBPATH:C:\\Users\\Jaden\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\x86_64-pc-windows-msvc\\lib’
Try '/usr/bin/link --help' for more information.
error: aborting due to previous error
error: could not compile `hello-rust`.
To learn more, run the command again with --verbose.
My research has turned up something about MSVC not being set up properly or something missing from the PATH variable. What does this error mean? I have Visual Studio 2017 installed (just the basics, I didn't check any of the workloads or individual components), and to my knowledge, that is MSVC (Microsoft Studio Visual C++). I'm new to Rust and low-level coding in general (I'm a Python/JavaScript guy), so I don't really understand what I need to do here. Could anyone give me guidance here?
Why is MSVC not installing or being recognized by Rust? What could cause this? How can I fix it?

I happened to find the answer by myself which I didn't find documented anywhere with regards to Rust. I searched longer about installing MSVC and found this Microsoft page: https://learn.microsoft.com/en-us/cpp/build/vscpp-step-0-installation?view=vs-2019
For core C and C++ support, choose the "Desktop development with C++" workload.
I modified my installation and selected the Desktop development with C++ workload. That worked!

When you install Rust using rustup-init.exe it should automatically detect whether you have the Microsoft C++ build tools installed. If they are not installed, it will give you a detailed message on how to install them as the very first thing.
This is what it looks like on Windows 10:
Rust Visual C++ prerequisites
Rust requires the Microsoft C++ build tools for Visual Studio 2013 or
later, but they don't seem to be installed.
The easiest way to acquire the build tools is by installing Microsoft
Visual C++ Build Tools 2019 which provides just the Visual C++ build
tools:
https://visualstudio.microsoft.com/downloads/#build-tools-for-visual-studio-2019
Please ensure the Windows 10 SDK and the English language pack components
are included when installing the Visual C++ Build Tools.
Alternately, you can install Visual Studio 2019, Visual Studio 2017,
Visual Studio 2015, or Visual Studio 2013 and during install select
the "C++ tools":
https://visualstudio.microsoft.com/downloads/
Install the C++ build tools before proceeding.
If you will be targeting the GNU ABI or otherwise know what you are
doing then it is fine to continue installation without the build
tools, but otherwise, install the C++ build tools before proceeding.
Continue? (Y/n)

Related

MSBuild using the wrong cl.exe when building with the 2015 C++ v140 Platform Toolkit

We're currently making a build environment for some of our projects.
In particular we're using VC++ 6.0 and VS2019 to build some of these projects.
When building our C++ project in VS2019 with the Platform Toolkit set to C++ 2015 v140, MSBuild attempts to use the VC++ 6.0 compiler to build the project. If I switch the Toolkit to any other version it builds with the correct cl.exe.
If I remove the VC98 folder that contains cl.exe from the path environment variable I get a cl.exe can't be found error in VS2019.
So I think there's something hardcoding the 2015 toolkit against the VC6.0 cl.exe.
I've tried installing and reinstalling the additional components in the VS Installer but no luck.
Repair of VS2019 didn't fix it either.
I've tried all versions of Visual Studio back to 2013 same issue.
This looks like an MSBuild issue, it's in the wrong location.
Is there any place where I can view the mapping for the toolkits in MSBuild? I couldn't see much in the registry.
The output when I build shows the following, the version is clearly a very old compiler (the VC6.0 one):
Microsoft (R) 32-bit C/C++ Optimizing Compiler Version 12.00.8804 for 80x86

Unable to install the VS2015 x64 Native Tools Command Prompt

I have installed the vc14 build tools but I could only get these tools: ARM cross tools, x86 native tools, x86 x64 cross tools. I've been told to install the Visual Studio community edition but nothing changed, I still only get those tools.
When I call vcvarsall.bat amd64 I'm getting the error: The specified configuration type is missing. The tools for the configuration might not be installed.
I am using Windows 7 Ultimate (64bit) and I should be able to compile x64 natively. Perhaps I need a newer OS? Or I need a paid Visual Studio version?

How to specify MS visual studio version for nexe?

I'm trying to compile my node.js project into a binary using nexe. I only have Microsoft Visual studio 2012, so the compiler complains it can't find MSVS2010
error MSB8020: The builds tools for Visual Studio 2010 (Platform Toolset = 'v100') cannot be found.
In nexe's requirement section, it does mention MSVS2012 can be supported, so I'd like to figure out a way to specify MSVS version.
I tried --msversion=2012 as in NPM installation but no luck.
Appreciate any advice on this.

Remove Visual Studio but keep C++ Compiler

I downloaded and installed Visual Studio Community 2013. Now I would like to remove VS but keep the MSVC++ compiler as I am using QtCreator. Is that possible?
You should try downloading the separate installer file for MSVC++ and install it after you uninstalled VS. Technically, the VS Uninstaller will also remove the MSVC++ program.
Sadly, there is not at this time any way to install just the Visual C++ toolset.

Where to find the VisualC++ x64 command-line compiler?

Where can I find the VisualC++ x64 compiler? It is not included in the SDK (not even x32 compiler is included). Please correct me if I'm wrong, but I could not find it in the SDK I just downloaded.
Note that I don't want to use the VisualC++ IDE (which includes the x32 compiler I'm currently using, but not the x64 compiler).
I'm wondering if I just missed something, because here, it seems like the SDK should include the x64 compiler (or at least any compiler).
If you have Visual Studio 2008 Installed: C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\bin\amd64. It is likely that the x64 Compiler was not installed. In VS-2008 that's the default install configuration. You can go back to your installer and select - install "x64 Compilers and Tools". If you are using Visual-Studio 2008 see: http://www.viva64.com/en/k/0006/
I have downloaded the free Trial version of Visual C++ 2010 Pro which includes the 64Bit compiler. The Trial only applies for the IDE, not for the command-line compiler. Works fine!

Resources