/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.

SpectreInstaller.png

Fix method two:

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

SpectreProperties.png

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章