I am getting the error:
C:\rust\hello_world\src>where link.exe
C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\VC\Tools\MSVC\14.24.28314\bin\Hostx64\x86\link.exe
C:\rust\hello_world\src>rustc main.rs
error: linking with `link.exe` failed: exit code: 1181
|
= note: "C:\\Program Files (x86)\\Microsoft Visual Studio\\2019\\BuildTools\\VC\\Tools\\MSVC\\14.24.28314\\bin\\HostX64\\x86\\link.exe" "/NOLOGO" "/NXCOMPAT" "/LARGEADDRESSAWARE" "/SAFESEH" "/LIBPATH:C:\\Users\\user\\.rustup\\toolchains\\stable-i686-pc-windows-msvc\\lib\\rustlib\\i686-pc-windows-msvc\\lib" "main.main.7rcbfp3g-cgu.0.rcgu.o" "main.main.7rcbfp3g-cgu.1.rcgu.o" "main.main.7rcbfp3g-cgu.2.rcgu.o" "main.main.7rcbfp3g-cgu.3.rcgu.o" "main.main.7rcbfp3g-cgu.4.rcgu.o" "main.main.7rcbfp3g-cgu.5.rcgu.o" "/OUT:main.exe" "main.4s37gsrti678ik8u.rcgu.o" "/OPT:REF,NOICF" "/DEBUG" "/NATVIS:C:\\Users\\user\\.rustup\\toolchains\\stable-i686-pc-windows-msvc\\lib\\rustlib\\etc\\intrinsic.natvis" "/NATVIS:C:\\Users\\user\\.rustup\\toolchains\\stable-i686-pc-windows-msvc\\lib\\rustlib\\etc\\liballoc.natvis" "/NATVIS:C:\\Users\\user\\.rustup\\toolchains\\stable-i686-pc-windows-msvc\\lib\\rustlib\\etc\\libcore.natvis" "/LIBPATH:C:\\Users\\user\\.rustup\\toolchains\\stable-i686-pc-windows-msvc\\lib\\rustlib\\i686-pc-windows-msvc\\lib" "C:\\Users\\user\\.rustup\\toolchains\\stable-i686-pc-windows-msvc\\lib\\rustlib\\i686-pc-windows-msvc\\lib\\libstd-a2af7cbca70405c4.rlib" "C:\\Users\\user\\.rustup\\toolchains\\stable-i686-pc-windows-msvc\\lib\\rustlib\\i686-pc-windows-msvc\\lib\\libpanic_unwind-8f8ad41ed0b34354.rlib" "C:\\Users\\user\\.rustup\\toolchains\\stable-i686-pc-windows-msvc\\lib\\rustlib\\i686-pc-windows-msvc\\lib\\libhashbrown-3442ca764a847dfc.rlib" "C:\\Users\\user\\.rustup\\toolchains\\stable-i686-pc-windows-msvc\\lib\\rustlib\\i686-pc-windows-msvc\\lib\\librustc_std_workspace_alloc-726244614f5a8f3a.rlib" "C:\\Users\\user\\.rustup\\toolchains\\stable-i686-pc-windows-msvc\\lib\\rustlib\\i686-pc-windows-msvc\\lib\\libbacktrace-29b7599014a92286.rlib" "C:\\Users\\user\\.rustup\\toolchains\\stable-i686-pc-windows-msvc\\lib\\rustlib\\i686-pc-windows-msvc\\lib\\librustc_demangle-519f7f7caa7ec7f2.rlib" "C:\\Users\\user\\.rustup\\toolchains\\stable-i686-pc-windows-msvc\\lib\\rustlib\\i686-pc-windows-msvc\\lib\\libunwind-feba7334127a8724.rlib" "C:\\Users\\user\\.rustup\\toolchains\\stable-i686-pc-windows-msvc\\lib\\rustlib\\i686-pc-windows-msvc\\lib\\libcfg_if-6d75d87de5ddb74c.rlib" "C:\\Users\\user\\.rustup\\toolchains\\stable-i686-pc-windows-msvc\\lib\\rustlib\\i686-pc-windows-msvc\\lib\\liblibc-7dc5efd24952e919.rlib" "C:\\Users\\user\\.rustup\\toolchains\\stable-i686-pc-windows-msvc\\lib\\rustlib\\i686-pc-windows-msvc\\lib\\liballoc-b95120d391119ce4.rlib" "C:\\Users\\user\\.rustup\\toolchains\\stable-i686-pc-windows-msvc\\lib\\rustlib\\i686-pc-windows-msvc\\lib\\librustc_std_workspace_core-0e624f0b43962fb3.rlib" "C:\\Users\\user\\.rustup\\toolchains\\stable-i686-pc-windows-msvc\\lib\\rustlib\\i686-pc-windows-msvc\\lib\\libcore-58985b8c03f907a8.rlib" "C:\\Users\\user\\.rustup\\toolchains\\stable-i686-pc-windows-msvc\\lib\\rustlib\\i686-pc-windows-msvc\\lib\\libcompiler_builtins-27c1b248396c205c.rlib" "advapi32.lib" "ws2_32.lib" "userenv.lib" "msvcrt.lib"
= note: LINK : fatal error LNK1181: cannot open input file 'C:\\Program.obj'
I've looked at other posts suggested by Stack Overflow as well as some Google results regarding this issue. I've tried to install and reinstall VS Community 2019 with C++ for desktop module, Visual Studio build tools with C++ build tools, the newest Windows 10 SDK with all options as well as the newest rustup-init installation. Where might my problem be?
You need to install Windows SDK
. Download Visual C++ Build Tools
from https://visualstudio.microsoft.com/downloads/ and select Windows SDK
during install. Or if If you have already installed it:
Windows Settings > Apps > Microsoft Visual C++ Build Tools > Modify > Windows SDK
After a lot of trial and error I discovered that I had previously installed mingw with GNU. Even if rust looked for link.exe in "...Microsoft Visual Studio\2019\BuildTools\VC\Tools\MSVC...", it was using GNU version not MSVC version of some dependencies. So in my case using not default(which is for MSVC which comes with VS) installation, but an GNU platform specific rust installation from https://forge.rust-lang.org/infra/other-installation-methods.html worked for me. Maybe if someone experienced could explain the issue in normal terms for future reference.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With