LINK : fatal error LNK1104: cannot open file 'MSVCRTD.lib'

前端 未结 19 3247
耶瑟儿~
耶瑟儿~ 2020-12-09 03:04

I\'m a novice C++ developer. I encontered the error message indicates \"LINK :fatal error LNK1104: cannot open file \'MSVCRTD.lib\'\" while I\'m trying to debug every single

相关标签:
19条回答
  • 2020-12-09 03:40

    I solved the problem by adding #using <mscorlib.dll> in the main file

    0 讨论(0)
  • 2020-12-09 03:40

    In VS2017 (Community/Enterprise/Ultimate/Professional):

    Add the path(s) of the folder(s) which include your desired ".lib" file(s) in the following path in VS:

    (Right Click)Project(in Solution Explorer)->Properties->Configuration Properties->Linker->General->Additional Library Directories

    If there are more than one ".lib" file use ';' to separate them otherwise click on the edit box corresponds to "Additional Library Directories" then click on "" in drop down menu and add all desired ".lib" files in newly opened window one by one and in a easy to handle manner.

    0 讨论(0)
  • 2020-12-09 03:42

    If you use VS2017, please read it. Or just ignore this answer...It may be invalid for other VS version.

    Do not trust anyone who told you to add lib path.

    Here's suggestions:

    • [BEST] You just need to install these via VS_installer (most of us just need x86/x64 version below)
      • VC++ 2017 version version_numbers Libs for Spectre [(x86 and x64) | (ARM) | (ARM64)]
      • Visual C++ ATL for [(x86/x64) | ARM | ARM64] with Spectre Mitigations
      • Visual C++ MFC for [x86/x64 | ARM | ARM64] with Spectre Mitigations
    • [NAIVE] or disable Spectre Option for every Solution (Why We are so hard to global disable it)
    • [LAUGH] Or never use VS2017

    This is VisualStudioTeam's fault and Microsoft is guilty.

    Why?

    You can't make a global configuration to disable /QSpectre, and IDK when and why VS2017 enable it in one day. So the best way is install Spectre? ahhha?

    0 讨论(0)
  • 2020-12-09 03:43

    I ran into this using Visual Studio 2017. I tried the solutions suggested here with explicitly adding paths to where the 'MSVCRT.lib' file was located. But I felt this probably wasn't the correct approach because previously for the past several weeks this had not been a problem with my project.

    After trial and error, I discovered that if I left an empty or blank value in the Linker --> Input section, it would give me the error about LNK1104: cannot open file 'MSVCRT.lib'. Eventually I figured out that I should leave this value there instead.

    On the Visual Studio project, right-Clicking on the project item in the Solution explorer panel (not the Solution itself, which is the topmost item), then select Properties. From there do the following:

    Linker --> Input : %(AdditionalDependencies)

    This additional information might be helpful, if you got into the situation the same way I did. I have discovered that I should not put any non-system library paths in the Linker --> Input section. With my project I was trying to compile with external .lib files. Previously I had a value in this input section like: $(ProjectDir)lib; %(AdditionalDependencies) but this lead to other problems. I discovered the correct place (it seems so far) to put paths for referencing external .lib files in a C/C++ project in Visual Studio 2017 is here:

    VC++ Directories --> Library Directories : $(ProjectDir)lib; $(LibraryPath)

    Note the $(LibraryPath) value will include extra values such as inherited from parents. My folder project contained a folder called 'lib' which is why I had the first value there before the semicolon.

    0 讨论(0)
  • 2020-12-09 03:45

    it is also worth checking that MSVCRTD.lib file is present in "C:\Program Files\Microsoft Visual Studio 10.0\VC\lib" for x64 and in C:\Program Files(x86)\Microsoft Visual Studio 10.0\VC\lib for 32 bit. Sometimes VS might not be installed properly OR these files might get deleted accidentally.

    0 讨论(0)
  • 2020-12-09 03:46

    I have solved this problem, you need install all spectre lib. Vistual Studio Installer->Modify->Component->Any spectre lib. This solution can be adapted to any project.

    0 讨论(0)
提交回复
热议问题