"Cannot open include file windows.h"

Hello guys,

I’ve been dealing with a problem for the past few hours. I used to use the engine just fine. But now it seems like it isn’t working for some reason. The only thing that I’ve changed since the last time I’ve used it is that I’ve installed Visual Assist X. Here’s what’s happening:

I created a new project and tried to add new code through the editor. When compiling the new code, I got an error message saying that “windows.h cannot be found”. When I closed the project and brought it back up, it first says:

**"the fellowing modules are missing or built with a different engine version:

[my project name]

Would you like to rebuild them now?"**

When I try to rebuild the solution I get this error:

**"[Project name] could not be compiled. Try rebuilding from source manually." **

When I try to rebuild from source I get the same “windows.h” could not be found. I’ve been all over the forums but I just cannot seem to find a solution. Can any one help me out?

windows.h is a windows-specific header that one (or more) of your files are depending on. To include the windows.h header in UE4 you need to wrap it in the following #include:



#include "AllowWindowsPlatformTypes.h"

#include "windows.h"

#include "HideWindowsPlatformTypes.h"


What do you mean wrap it? Do I have to include those in all my files?

This happens on our school’s lab computers, and we have a solution to deal that problem for all lab computers imaged:

Solution:

I do not know if this is the default behavior, so in Visual Studio 2013 Community (and Professional, which we use in our school), by default <windows.h> should be included in the installation.

Go to your Project Properties ([your project name] Properties, not the Engine Properties).

Go to VC++ Directories

Set all blank entries to <Inherit Parent or Default Values>. Do not change or modify the entries that have values in them, as those are for UE4 specifics.

Tried that. Does not work

[Edit]

My windows sdk is on the C Drive, but my visual studio and engine are on another drive. Would that have to do any thing with my problem?

Any other ideas? I’m seriously considering reinstalling my whole OS

Your OS should have nothing to do with the SDK. As long as your VC++ Directories for the project are pointing at where ever you installed the Windows SDK, you should be fine. You can always go re-download and re-install the Windows 8.1 SDK to see if that fixes things:

Here you can see if I open up my include directories, there’s simply an environment variable that is set by the Windows 8.1 SDK installer to point to the Windows SDK directory, if that got messed up somehow then you’d run into the issue you are seeing now.

EDIT:

Also make sure you re-generate your project solution if you re-install the SDK to pick up any changes.

I reinstalled the SDK, that did not work either.

By wrapping, I mean surrounding the <windows.h> within


#include "AllowWindowsPlatformTypes.h"
// define windows-platform specific includes here
#include "HideWindowsPlatformTypes.h"

You don’t have to include that in all of your files. You would only do this within a file that requires <windows.h> or other windows-specific headers to be included.

It shouldn’t matter if your windows sdk and your visual studio installs are on separate drives because they are both installed to the same OS, unless you mean you have separate bootable windows installs on each drive, in which case, yes it would matter.

I’m not sure what would be requiring the windows header without having manually added something yourself that requires it but stranger things have happened. Rather than trying to open the .uproject file, open the visual studio solution that was created for your project, run a build, then run a debug to launch the editor. The debug will rebuild the editor for you and it should either load up normally or give a clue as to any errors that are stopping a successful build. If the build succeeds, you will be able to open your project in the editor next time by clicking on the .uproject file as normal again.

Give it a shot and post if there are any errors from that.

Here’s an error I’m getting while building it from visual studio:

“ERROR: Failed to start local process for action: C:\Program Files (x86)\Windows Kits\8.1\bin/x64/rc.exe”

And then I get the following errors after:

  1. “d:\epic games\4.7\engine\source\runtime\core\public\Windows/MinWindows.h(62): fatal error C1083: Cannot open include file: ‘windows.h’: No such file or directory”

  2. 1>C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V120\Microsoft.MakeFile.Targets(38,5): error MSB3073: The command ““D:\Epic Games\4.7\Engine\Build\BatchFiles\Build.bat” TestProjecting Win64 DebugGame “D:\Dev\Unreal Projects\TestProjecting\TestProjecting.uproject” -rocket” exited with code -1.

It works! My SDK install was corrupted. I ran a repair on it and now every thing is working. Thank you and every one else for the help.