LNK1104: cannot open file 'msvcrt.lib'

Ever since I updated to 1.92.0, some of my dependencies' dependencies cause trouble linking.

Now, I know this issue might not be Rust-specific, since Googling this shows the same problem for C++, but I'm not acquainted enough to know what any of the error messaging means, and I'm hoping that you can be of help.

I've tried reinstalling Rust using rustup self uninstall and I (re)installed the latest MSVC just to be sure.

"C:\\Program Files\\Microsoft Visual Studio\\2022\\Community\\VC\\Tools\\MSVC\\14.44.35207\\bin\\HostX64\\x64\\link.exe" "/NOLOGO" "(my user folder)\\AppData\\Local\\Temp\\rustcsPcQgD\\symbols.o" "<3 object files omitted>" "<sysroot>\\lib\\rustlib\\x86_64-pc-windows-msvc\\lib/{libstd-*,libpanic_unwind-*,libcfg_if-*,libwindows_targets-*,librustc_demangle-*,libstd_detect-*,libhashbrown-*,librustc_std_workspace_alloc-*,libunwind-*,librustc_std_workspace_core-*,liballoc-*,libcore-*,libcompiler_builtins-*}.rlib" "kernel32.lib" "kernel32.lib" "kernel32.lib" "ntdll.lib" "userenv.lib" "ws2_32.lib" "dbghelp.lib" "/defaultlib:msvcrt" "/NXCOMPAT" "/OUT:(my project folder)\\target\\debug\\build\\rustversion-794a1f2e5527248c\\build_script_build-794a1f2e5527248c.exe" "/OPT:REF,NOICF" "/DEBUG" "/PDBALTPATH:%_PDB%" "/NATVIS:<sysroot>\\lib\\rustlib\\etc\\intrinsic.natvis" "/NATVIS:<sysroot>\\lib\\rustlib\\etc\\liballoc.natvis" "/NATVIS:<sysroot>\\lib\\rustlib\\etc\\libcore.natvis" "/NATVIS:<sysroot>\\lib\\rustlib\\etc\\libstd.natvis"
  = note: some arguments are omitted. use `--verbose` to show all linker arguments
  = note: LINK : fatal error LNK1104: cannot open file 'msvcrt.lib'
2 Likes

Shotgun approach, but it often works for me for things like this: try deleting the target build folder for your rust project, if you haven't already.

I installed:

  • MSVC v143 - VS 2022 C++ x64/x86 build tools
  • Windows 10/11 SDK (any recent one)

via Visual Studio Installer. They were removed for some reason. This worked. Credits to ChatGPT.