/Qspectre option causes "LNK1104 cannot open file 'MSVCRTD.lib'" error in VS2017

Intro

This page records two ways to fix the  "LNK1104 cannot open file 'MSVCRTD.lib'" with Spectre in VS2017.

The Spectre mitigation for VS2017

https://aka.ms/Ofhn4c

Warning	MSB8038	Spectre mitigation is enabled but Spectre mitigated libraries are not found.  Verify that the Visual Studio Workload includes the Spectre mitigated libraries.  See https://aka.ms/Ofhn4c for more information.	WindowsProject1	C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\Common7\IDE\VC\VCTargets\Microsoft.CppBuild.targets	402	

Problem

  1. On fresh Windows 10. Install Visual Studio 2017 version 15.8.9.
  2. Create new "Visutal C++ \ Windows Desktop Application" project with wizard.
  3. Compile the project will get below link error:
1>LINK : fatal error LNK1104: cannot open file 'MSVCRTD.lib'
1>Done building project "WindowsProject1.vcxproj" -- FAILED.

Reason and how to fix the problem:

Reason:

If you build your code by using /Qspectre and these libraries are not installed, the build system reports warning MSB8038: Spectre mitigation is enabled but Spectre mitigated libraries are not found. If your MFC or ATL code fails to build and the linker reports an error such as fatal error LNK1104: cannot open file 'oldnames.lib', these missing libraries may be the cause.

Fix metod one:

As the Spectre mitigations in MSVC blog said, you can install the "* for Spectre" components.

/Qspectre option causes

Fix method two:

You can disable the Spectre by setting "Spectre Mitigation" = "Disabled"

/Qspectre option causes

 

你可能感兴趣的:(Visual,Studio)