rustup: link.exe problem on Windows 10
Hi all, I installed the MS C++ Build Tools as requested by rustup-init.exe and rebooted, but I am unable to build a hello world app with cargo:
? cargo run
Compiling hello v0.1.0 (file:///C:/Users/myusername/Documents/hello)
error: linking with `link.exe` failed: exit code: 1
|
= note: "link.exe" "/NOLOGO" "/NXCOMPAT" "/LIBPATH:C:\\Users\\myusername\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\x86_64-pc-windows-msvc\\lib" "C:\\Users\\myusername\\Documents\\hello\\target\\debug\\deps\\hello-82df257bc2a2633d.10ygozpgsu0ud2lu.rcgu.o" "C:\\Users\\myusername\\Documents\\hello\\target\\debug\\deps\\hello-82df257bc2a2633d.1y16o1qfye96o7m0.rcgu.o" "C:\\Users\\myusername\\Documents\\hello\\target\\debug\\deps\\hello-82df257bc2a2633d.3rngp6bm2u2q5z0y.rcgu.o" "C:\\Users\\myusername\\Documents\\hello\\target\\debug\\deps\\hello-82df257bc2a2633d.4oc10dk278mpk1vy.rcgu.o" "C:\\Users\\myusername\\Documents\\hello\\target\\debug\\deps\\hello-82df257bc2a2633d.4xq48u46a1pwiqn7.rcgu.o" "C:\\Users\\myusername\\Documents\\hello\\target\\debug\\deps\\hello-82df257bc2a2633d.544l4wfz89vbhoea.rcgu.o" "/OUT:C:\\Users\\myusername\\Documents\\hello\\target\\debug\\deps\\hello-82df257bc2a2633d.exe" "C:\\Users\\myusername\\Documents\\hello\\target\\debug\\deps\\hello-82df257bc2a2633d.crate.allocator.rcgu.o" "/OPT:REF,NOICF" "/DEBUG" "/NATVIS:C:\\Users\\myusername\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\etc\\intrinsic.natvis" "/NATVIS:C:\\Users\\myusername\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\etc\\liballoc.natvis" "/NATVIS:C:\\Users\\myusername\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\etc\\libcore.natvis" "/LIBPATH:C:\\Users\\myusername\\Documents\\hello\\target\\debug\\deps" "/LIBPATH:C:\\Users\\myusername\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\x86_64-pc-windows-msvc\\lib" "C:\\Users\\myusername\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\x86_64-pc-windows-msvc\\lib\\libstd-9f1edc24d0b74e0c.rlib" "C:\\Users\\myusername\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\x86_64-pc-windows-msvc\\lib\\libpanic_unwind-2d50f247da360a48.rlib" "C:\\Users\\myusername\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\x86_64-pc-windows-msvc\\lib\\libunwind-eb42664d0182a79c.rlib" "C:\\Users\\myusername\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\x86_64-pc-windows-msvc\\lib\\liblibc-38159e862df1f40b.rlib" "C:\\Users\\myusername\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\x86_64-pc-windows-msvc\\lib\\liballoc_system-9e685589a65e5f9b.rlib" "C:\\Users\\myusername\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\x86_64-pc-windows-msvc\\lib\\liballoc-cb5a1bd9bdafe27f.rlib" "C:\\Users\\myusername\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\x86_64-pc-windows-msvc\\lib\\libcore-bace9445355015e4.rlib" "C:\\Users\\myusername\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\x86_64-pc-windows-msvc\\lib\\libcompiler_builtins-37f282c12d20ae8e.rlib" "advapi32.lib" "ws2_32.lib" "userenv.lib" "shell32.lib" "msvcrt.lib"
= note: /usr/bin/link: extra operand '/LIBPATH:C:\\Users\\myusername\\.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`.
To learn more, run the command again with --verbose.
It appears that it’s running the GNU link command rather than the MSVC one. Could this be a path problem? Here is my path:
C:\Users\myusername\Downloads\cmder_mini\bin;C:\Users\myusername\Downloads\cmder_mini\vendor\conemu-maximus5\ConEmu\Scripts;C:\Users\myusername\Downloads\cmder_mini\vendor\conemu-maximus5;C:\Users\myusername\Downloads\cmder_mini\vendor\conemu-maximus5\ConEmu;C:\Program Files\Docker\Docker\Resources\bin;C:\ProgramData\Oracle\Java\javapath;C:\windows\system32;C:\windows;C:\windows\System32\Wbem;C:\windows\System32\WindowsPowerShell\v1.0\;C:\Program Files\Perforce;C:\Program Files\Git\cmd;C:\Users\myusername\.cargo\bin;C:\Users\myusername\AppData\Local\Microsoft\WindowsApps;C:\Users\myusername\AppData\Local\atom\bin;C:\Program Files\Git\mingw64;C:\Program Files\Git\usr\bin;C:\Users\myusername\Downloads\cmder_mini
About this issue
- Original URL
- State: closed
- Created 6 years ago
- Reactions: 10
- Comments: 17 (4 by maintainers)
Thanks for the help everyone. I fixed this by:
Adding
c:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\VC\Tools\MSVC\14.14.26428\bin\Hostx64\x64\to my system Path, thenInstalling “Windows 10 SDK (10.0.15063) for Desktop C++” as described at https://github.com/rust-lang/rust/issues/43039
For people who want to spare time and brain cells, here is how to compile a rust program in clean Windows installation:
Press Win key, search for “powershell”, launch
Windows Powershellas administrator.You should now be able compile, install and use whatever Rust software you want:
This is definitely a path problem. Make sure you don’t have a conflicting
link.exeon your PATH. You can see the currentlink.exeby runningwhere link.exein cmd orGet-Command link.exein powershell.can someone help me?
Rust does not blindly invoke
link.exeunless it is unable to locate all the necessary components. If all the necessary components are installed then Rust will be able to locate them itself, noPATHmodifications necessary.When using the Visual Studio Installer please make sure you have at least one of the
VC++ 2017 version 15.x toolsinstalled and one of theWindows 10 SDKs (if there are multiple variants for a version, choose the desktop x86 x64 version) installed. If you have both of those components and Rust is still not able to detect VC++, then reach out to me so I can help diagnose the issue (and eventually get that corner case fixed in Rust).@AaronM04 What version of the build tools did you install? I think Rust specifically requires the Visual C++ Build Tools 2015 which seem hard to come by these days (see https://github.com/rust-lang-nursery/rustup.rs/issues/1454)