简体   繁体   中英

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:

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

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.

It appears to be part of the Windows SDK, if Google leads me right. However, I did not have to download the Windows SDK separately in order to compile my project and run it successfully before. (For context, the project's been developed for a few months and this problem only emerged a week or so ago).

My QT Installation:

  • Kit: Desktop Qt 5.15.2 MSVC2015 64bit
  • Version: Qt 5.15.2 MSVC2015 64bit
  • Compiler: Microsoft Visual C++ Compiler 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.
  • The company's recently had issues with Microsoft Intune deleting applications. Maybe it hit the Windows SDK too.

Attempts at Solving the Issue

  1. Reinstallation of Qt 5.15.2
  • Expected: My project building without errors. Result: This error.
  1. Search of file system for 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.

Update: MinGW 64 bit works for the example Qt projects, but I'd still like to use MSVC2015 if possible. It doesn't work for my project because I use some MSVC specific pre-processor flags in my source.

Update 2: I attempted to re-download MSVC 2015 from Visual Studio's website, using their Build Tools installer. While the installation successfully finished, I got no change from before -- it still can't find that "objbase.h" file. It's supposed to be in the Windows Kits directory under Include//um, I think.

It appears that, in my case, the objbase.h file was deleted due to the issue with Windows Defender deleting random files. I was able to reinstall the version of Windows SDK that was using and this fixed the issue for me.

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

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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