简体   繁体   English

QT Creator 在调用 nmake 时找不到“objbase.h”

[英]QT Creator cannot find "objbase.h" when invoking nmake

When attempting to build my Qt project with MSVC2015 64bit for Windows 10, I get this error:当尝试使用 MSVC2015 64 位为 Windows 10 构建我的 Qt 项目时,出现此错误:

C:\Program Files (x86)\Windows Kits\10\Include\10.0.19041.0\um\Ole2.h:37: error: C1083: Cannot open include file: 'objbase.h': No such file or directory
...
NMAKE:-1: error: U1077: '"C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.33.31629\bin\HostX64\x64\cl.EXE"' : return code '0x2'
NMAKE:-1: error: U1077: '"C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.33.31629\bin\HostX64\x64\nmake.exe"' : return code '0x2'

-- when nmake is invoked during the build process. -- 在构建过程中调用 nmake 时。 This exact same error also occurs for the example project "addressbook".这个完全相同的错误也发生在示例项目“地址簿”中。

It appears to be some kind of toolchain issue, but I can compile a Qt Widget project in Microsoft Visual Studio 2022 if I point VS at my Qt installation.这似乎是某种工具链问题,但如果我将 VS 指向我的 Qt 安装,我可以在 Microsoft Visual Studio 2022 中编译一个 Qt Widget 项目。

I'm not sure what I need to do from here, since I already tried a reinstall of Qt. I have seen that putting things in Program Files is generally a bad idea, but that doesn't seem to be the issue in this specific case.我不确定我需要从这里做什么,因为我已经尝试重新安装 Qt。我已经看到将东西放入程序文件通常是个坏主意,但这似乎不是这个特定的问题案件。

It appears to be part of the Windows SDK, if Google leads me right.如果谷歌引导我正确的话,它似乎是 Windows SDK 的一部分。 However, I did not have to download the Windows SDK separately in order to compile my project and run it successfully before.不过,之前我的工程编译运行成功,并不是必须要单独下载Windows SDK。 (For context, the project's been developed for a few months and this problem only emerged a week or so ago). (就上下文而言,该项目已经开发了几个月,而这个问题仅在一周左右前出现)。

My QT Installation:我的 QT 安装:

  • Kit: Desktop Qt 5.15.2 MSVC2015 64bit套件:桌面 Qt 5.15.2 MSVC2015 64 位
  • Version: Qt 5.15.2 MSVC2015 64bit版本:Qt 5.15.2 MSVC2015 64位
  • Compiler: Microsoft Visual C++ Compiler 17.3.32811.315 (amd64)编译器:Microsoft Visual C++ 编译器 17.3.32811.315 (amd64)

Things That Have Happened Before My Build Attempt:在我尝试构建之前发生的事情:

  • I recently reinstalled Qt 5.15.2 in an effort to resolve a similar missing file issue.我最近重新安装了 Qt 5.15.2 以解决类似的丢失文件问题。
  • The company's recently had issues with Microsoft Intune deleting applications.该公司最近遇到了 Microsoft Intune 删除应用程序的问题。 Maybe it hit the Windows SDK too.也许它也击中了 Windows SDK。

Attempts at Solving the Issue尝试解决问题

  1. Reinstallation of Qt 5.15.2重装Qt 5.15.2
  • Expected: My project building without errors.预期:我的项目构建没有错误。 Result: This error.结果:这个错误。
  1. Search of file system for objbase.h在文件系统中搜索 objbase.h
  • Expected: Finding the file.预期:查找文件。 Result: I did not find the file.结果:我没有找到该文件。

I'm newish at Qt, so I didn't want to try anything more esoteric lest I made things worse than before.我是 Qt 的新手,所以我不想尝试任何更深奥的东西,以免我把事情弄得比以前更糟。

Update: MinGW 64 bit works for the example Qt projects, but I'd still like to use MSVC2015 if possible.更新:MinGW 64 位适用于示例 Qt 项目,但如果可能,我仍然希望使用 MSVC2015。 It doesn't work for my project because I use some MSVC specific pre-processor flags in my source.它不适用于我的项目,因为我在我的源代码中使用了一些 MSVC 特定的预处理器标志。

Update 2: I attempted to re-download MSVC 2015 from Visual Studio's website, using their Build Tools installer.更新 2:我尝试使用他们的构建工具安装程序从 Visual Studio 的网站重新下载 MSVC 2015。 While the installation successfully finished, I got no change from before -- it still can't find that "objbase.h" file.虽然安装成功完成,但与之前相比没有任何变化——它仍然找不到“objbase.h”文件。 It's supposed to be in the Windows Kits directory under Include//um, I think.我认为它应该位于 Include//um 下的 Windows Kits 目录中。

It appears that, in my case, the objbase.h file was deleted due to the issue with Windows Defender deleting random files.就我而言,由于 Windows Defender 删除随机文件的问题,objbase.h 文件似乎已被删除。 I was able to reinstall the version of Windows SDK that was using and this fixed the issue for me.我能够重新安装正在使用的 Windows SDK 版本,这为我解决了这个问题。

I figured it out.我想到了。 I'm posting the solution here for others.我在这里为其他人发布解决方案。

My issue was that, for reasons that are unclear to me, VS Studio Build Tools would not actually remove the SDK in question if I unchecked its box in the Modify screen.我的问题是,出于我不清楚的原因,如果我在修改屏幕中取消选中它的框,VS Studio 构建工具实际上不会删除有问题的 SDK。 You can tell if this is happening by checking the disk size difference of the upcoming installation in the lower right of the screen -- if it won't remove the SDK, that size will be +0 bytes (assuming you don't check or uncheck any other box).您可以通过检查屏幕右下角即将安装的磁盘大小差异来判断是否发生这种情况——如果它不会删除 SDK,则该大小将为 +0 字节(假设您不检查或取消选中任何其他框)。

In order to properly reinstall the SDK version, I had to go to "Add or remove programs" and find the SDK there, uninstall it, restart my computer just for safety, and then go to VS Build Tools and install that SDK version.为了正确重新安装 SDK 版本,我不得不 go 到“添加或删除程序”并在那里找到 SDK,卸载它,为了安全起见重新启动我的计算机,然后go 到 VS 构建工具并安装 SDK 版本。 I had to do a "fake" uninstall with VS Build Tools (basically, uncheck the now-deleted SDK and click "Modify", allowing it to do the installation and download steps) before I could actually install the SDK again.在我再次实际安装 SDK 之前,我必须使用 VS Build Tools 进行“假”卸载(基本上,取消选中现已删除的 SDK 并单击“修改”,允许它执行安装和下载步骤)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM