C++ 链接:致命错误 LNK1104:无法打开文件“MSVCRTD.lib”
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/6228112/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
LINK : fatal error LNK1104: cannot open file 'MSVCRTD.lib'
提问by kommihe
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.0\VC\lib", but that file is not there in my case. What should I do?
我是 C++ 开发新手。当我尝试调试 Microsoft Visual C++ 2010 Express 中的每个项目时,我遇到了错误消息指示“链接:致命错误 LNK1104:无法打开文件‘MSVCRTD.lib’”。我在 Stack Overflow 和 Google 上搜索了任何可能的解决方案,但找不到准确的答案。我所理解的是“msvcrtd.lib”文件应该在“\Microsoft Visual Studio 10.0\VC\lib”中,但在我的情况下该文件不存在。我该怎么办?
回答by Roham Pardakhtim
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:
对于那些为此苦苦挣扎的可怜人,经过一个小时的研究,我找到了适用于 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
使用 Windows 资源管理器,转到安装 Visual Studio 的目录(默认:C:\Program Files (x86)\Microsoft Visual Studio)并搜索msvcrtd.lib
I found mine to be in here:
我发现我的在这里:
C:\Program Files (x86)\Microsoft Visual Studio17\Enterprise\VC\Tools\MSVC.15.26726\lib\onecore\x86
Quick Fix (for one project only):
快速修复(仅针对一个项目):
- Right click on your project, click on properties, navigate to Linker, add that path to Additional Library Directories
Permanent Fix (for all projects)
永久修复(适用于所有项目)
- Open a project
- navigate to View > Property Manager (it could be under Other Windows)
- Expand all folders and multi select all "Microsoft.cpp.Win32.user" & "Microsoft.cpp.64.user"
- 打开一个项目
- 导航到 View > Property Manager(它可能在Other Windows 下)
- 展开所有文件夹并多选所有“ Microsoft.cpp.Win32.user”和“ Microsoft.cpp.64.user”
- Right click and go to properties
Add the path to default Library Directories
回答by arman_aegit
Go to your project properties, select Linker from left. Add this to "Additional Library Directories":
转到您的项目属性,从左侧选择链接器。将此添加到“附加库目录”:
"(Your Visual Studio Path)\VC\lib"
For example:
例如:
C:\Program Files\Microsoft Visual Studio 10.0\VC\lib
回答by MahanGM
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 Includeand Librarydirectories property windows and of course for your Additional Dependencieswindow.
在项目属性的某些属性对话框中有一个复选框,上面写着“从父级或项目默认值继承”。确保选中包含和库目录属性窗口以及附加依赖项窗口的复选框。
回答by Sanbrother
回答by zxj5470
If you use VS2017, please read it. Or just ignore this answer...It may be invalid for other VS version.
如果您使用VS2017,请阅读。或者只是忽略这个答案......它可能对其他 VS 版本无效。
Do not trust anyone who told you to add lib path.
不要相信任何告诉你添加 lib 路径的人。
Here's suggestions:
以下是建议:
- [BEST] You justneed to install these via
VS_installer
(most of us just needx86/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
- [BEST] 你只需要通过安装这些
VS_installer
(我们大多数人只需要x86/x64
下面的版本)- 用于 Spectre [(x86 和 x64) | 的 VC++ 2017 版本 version_numbers Libs (ARM) | (ARM64)]
- 用于 [(x86/x64) | 的 Visual C++ ATL | 手臂 | ARM64] 与 Spectre 缓解
- Visual C++ MFC for [x86/x64 | 手臂 | ARM64] 与 Spectre 缓解
- [NAIVE] 或禁用
Spectre
每个解决方案的选项(为什么我们很难全局禁用它) - [笑] 或者永远不要使用 VS2017
This is VisualStudioTeam's fault and Microsoft is guilty.
这是 VisualStudioTeam 的错,微软有罪。
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?
你不能做一个全局配置来禁用/QSpectre
, 和 IDK 什么时候以及为什么 VS2017 在一天内启用它。所以最好的方法是安装Spectre
?啊哈?
回答by JoeEngineer
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.
我遇到了这个问题。该文件存在于我的机器上,它在搜索路径中。我被难住了,因为错误结果真的没有帮助。在我的例子中,我打开了 Spectre 缓解,但没有下载 Spectre 的运行时库。一旦我完成下载,世界就一切正常。我也必须在我的 CI 构建服务器上安装它,因为默认情况下这些库没有安装在 VS 中。
回答by BHeroo
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.
我已经解决了这个问题,你需要安装所有的幽灵库。 Visual Studio Installer->Modify->Component->Any spectre lib。该解决方案可适用于任何项目。
回答by zezba9000
For me this issue happens after installing the (Windows Driver Kit): https://docs.microsoft.com/en-us/windows-hardware/drivers/download-the-wdk
对我来说,安装(Windows 驱动程序工具包)后会发生此问题: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
卸载它可以解决问题。只是在这里发布作为寻找解决方案的人的相关问题:安装 WDK VC++ 后坏了
回答by Ted
Scenario:
设想:
Windows 10with Visual Studio 2017(FRESH installation).
'C' project(LINK : fatal error LNK1104: cannot open file 'MSVCRTD.lib').
带有Visual Studio 2017 的Windows 10(全新安装)。
“C”项目(链接:致命错误 LNK1104:无法打开文件“ MSVCRTD.lib”)。
Resolve:
解决:
Run 'Visual Studio Installer'.
Click button 'Modify'.
Select 'Desktop development with C++'.
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.
- Click button 'Modify', to apply changes.
Right-click 'SomeProject' -> 'Properties' -> 'Linker' -> 'General' -> 'Additional Library Directories': $(VCToolsInstallDir)\lib\x86
(!!! for x64project: 'Additional Library Directories': $(VCToolsInstallDir)\lib\x64 !!!)
运行“ Visual Studio 安装程序”。
单击“修改”按钮。
选择“使用 C++ 进行桌面开发”。
从“安装详细信息”(通常在右侧栏)中选择:
4.1. VC++ 2015.3 v14.00(v140) 桌面工具集。
- 4.1 中的“工具集”版本。只是举例。
- 单击“修改”按钮以应用更改。
右键单击“SomeProject”->“属性”->“链接器”->“常规”->“附加库目录”:$(VCToolsInstallDir)\lib\x86
(!!!对于x64项目:'附加库目录':$(VCToolsInstallDir)\lib\x64 !!!)
回答by irsis
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.
还值得检查 MSVCRTD.lib 文件是否存在于 x64 的“C:\Program Files\Microsoft Visual Studio 10.0\VC\lib”和 C:\Program Files(x86)\Microsoft Visual Studio 10.0\VC\lib对于 32 位。有时 VS 可能没有正确安装,或者这些文件可能会被意外删除。