Question

[Solved] LINK : fatal error LNK1104: cannot open file ‘MSVCRTD.lib’

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 project in Microsoft Visual C++ 2010 Express. I searched on Stack overflow and Google for any possible resolution, but I couldn’t find exact and precise answer. What I have understood is that the “msvcrtd.lib” file should be in “Microsoft Visual Studio 10.0VClib”, but that file is not there in my case. What should I do?

Enquirer: kommihe

||

Solution #1:

For the poor souls out there who are struggling with this, after an hour of research I found a solution for my Visual Studio Enterprise 2017:

First, lets find where is your library file located:

With windows explorer, go to your directory where Visual Studio is installed, (default: C:Program Files (x86)Microsoft Visual Studio) and do a search for msvcrtd.lib

I found mine to be in here:

C:Program Files (x86)Microsoft Visual Studio2017EnterpriseVCToolsMSVC14.15.26726libonecorex86

Quick Fix (for one project only):

  1. Right click on your project, click on properties, navigate to Linker, add that path to Additional Library Directories
    enter image description here

Permanent Fix (for all projects)

  1. Open a project
  2. navigate to View > Property Manager (it could be under Other Windows)
  3. Expand all folders and multi select all “Microsoft.cpp.Win32.user” & “Microsoft.cpp.64.user

enter image description here

  1. Right click and go to properties
  2. Navigate to VC++ Directories
    enter image description here

  3. Add the path to default Library Directories

Respondent: Roham Pardakhtim

Solution #2:

Go to your project properties, select Linker from left. Add this to “Additional Library Directories“:

"(Your Visual Studio Path)VClib"

For example:

C:Program FilesMicrosoft Visual Studio 10.0VClib
Respondent: arman_aegit

Solution #3:

I came across this problem when compiling a sample app using VS2017
Hope this will help

enter image description here

Respondent: Sanbrother

Solution #4:

There is a check box that says “Inherit from parent or project defaults” in some of the property dialogs in Project Properties. Make sure that check box is checked for your Include and Library directories property windows and of course for your Additional Dependencies window.

Respondent: MahanGM

Solution #5:

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?

Respondent: zxj5470

Solution #6:

I ran into this issue. The file existed on my machine, it was in the search path. I was stumped as the error result is really unhelpful. In my case I had turned on Spectre mitigation, but had not downloaded the runtime libs for Spectre. Once I did the download all was right with the world. I had to get this installed on my CI build servers also, as these libs are not installed with VS by default.

Respondent: JoeEngineer

Solution #7:

For VS 2019, Spectre Mitigation is enabled by default.
So the right way to fix the issue would be to install VC++ Libs for Spectre.

But, to quickly resolve the issue, you may disable Spectre Mitigation

Project Properties -> C/C++ -> Code Generation -> Spectre Mitigation -> Disabled

enter image description here

https://devblogs.microsoft.com/cppblog/spectre-mitigations-in-msvc/

Respondent: Madhur

Solution #8:

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.

Respondent: BHeroo

Solution #9:

For me this issue happens after installing the (Windows Driver Kit): https://docs.microsoft.com/en-us/windows-hardware/drivers/download-the-wdk

Uninstalling it fixes the problem. Just posting here as a related issue for people looking for solutions: After installing WDK VC++ is broken

Respondent: zezba9000

Solution #10:

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

Respondent: irsis

Solution #11:

Scenario:

  1. Windows 10 with Visual Studio 2017 (FRESH installation).

  2. ‘C’ project (LINK : fatal error LNK1104: cannot open file ‘MSVCRTD.lib‘).

Resolve:

  1. Run ‘Visual Studio Installer‘.

  2. Click button ‘Modify’.

  3. Select ‘Desktop development with C++‘.

  4. From “Installation details”(usually on the right-sidebar) select:

    4.1. VC++ 2015.3 v14.00(v140) toolset for desktop.

    • Version of ‘toolset’ in 4.1. is just for example.
  5. Click button ‘Modify’, to apply changes.
  6. Right-click ‘SomeProject’ -> ‘Properties’ ->
    Linker‘ ->
    General‘ ->
    Additional Library Directories‘: $(VCToolsInstallDir)libx86

    (!!! for x64 project: ‘Additional Library Directories’: $(VCToolsInstallDir)libx64 !!!)

Respondent: Ted

Solution #12:

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

Respondent: Adrian

Solution #13:

This indicates that Visual Studio wasn’t able to find the lib (Library) directory which contains msvcrtd.lib.

IMPORTANT: This lib directory also contains linkers required during the compilation process.

So, all you need to do is override the Library Directory location. You can do so with the help of Environment Variables.

I referred to this StackOverflow Post for help. As per the answer posted, the Environment Variable LIB refers to the path where the Linker Libraries are located. Why is this method better? Because this will apply to all the projects instead of just a particular project. Also, you don’t need to download anything extra. It just works…

Follow the steps below to achieve this:

STEP-1: Search for “msvcrtd.lib” in the search bar.

STEP-2: Click “Open File Location” (available in context menu)

enter image description here

STEP-3: Copy the address of the directory from the address bar.

enter image description here

STEP-4: Search “Environment” in the taskbar and click on “Edit the system environment variables”.

enter image description here

STEP-5: Click on “Environment Variables…” button.

enter image description here

STEP-6: Under “System variables” section, click on “New…” button. A dialog would pop up.

enter image description here

STEP-7: In the dialog box, enter the following:

  • Variable name: LIB
  • Variable value: [The directory you copied in “STEP-3”]

And press “OK”

enter image description here

Now, you are all done!

Respondent: Melvin Abraham

Solution #14:

The above answer was not quite accurate for me. I have VS2010 Ultimate installed and the file in question is not in my Visual Studio 10.0VC folder. Rather I found it in the Visual Studio 9.0VC folder. So if that’s the case for anyone, follow the lead to change the Linker but use the Visual Studio 9.0VC folder instead. It worked for me.

Respondent: Skip

Solution #15:

For Visual Studio 2017
Go to your project properties, select Linker from left. Add this to “Additional Library Directories”:

C:Program Files (x86)Microsoft Visual StudioShared14.0VClib

Respondent: Murat Gungor

Solution #16:

I got a slightly different error

LNK1104 cannot open file ‘MSVCURTD.lib’

Note it is msvcUrtd (not msvcrtd), but the file is not found on my system.

Solved it by setting the following options:

Project Properties
 General
  Character Set: Not Set
  Common Language Runtime Support: Common Language Runtime Support (/clr)

Hope that helps.

Solution #17:

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.

Respondent: amirfg

Solution #18:

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.

Respondent: C.D.

Solution #19:

I have included the following path

C:Program Files (x86)Microsoft Visual Studio2017CommunityVCToolsMSVC14.16.27023libx86
and
C:localboost_1_64_0lib64-msvc-14.1

To

project properties-> linker-> Additional Directories

Click here : Image shows linking of boost and MSVC2017

Respondent: Harsh Tamrakar

The answers/resolutions are collected from stackoverflow, are licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0 .

Most Popular

To Top
India and Pakistan’s steroid-soaked rhetoric over Kashmir will come back to haunt them both clenbuterol australia bossier man pleads guilty for leadership role in anabolic steriod distribution conspiracy