Cannot open include file 'windows.h'

I’ve just set up FlashDevelop so I can have a play with HaxeFlixel. I’m not sure if this is even the right forum to be asking about this problem as there seems to be so many different things I had to install (i.e. haxe, openfl, lime, haxeflixel, flashdevelop, etc…). So I don’t even know where to start looking to solve this error I’m getting.

I am able to compile and run an example project in flash, html5 and neko, but if I try and compile and run it for windows, I get the following error.

C:\HaxeToolkit\haxe\lib\hxcpp\3,2,102\include\hx/Thread.h(15) : fatal error C1083: Cannot open include file: 'windows.h': No such file or directory

I don’t really understand why I’m getting this error as I’m pretty sure I’ve followed all the docs on each website carefully. I’ve also searched around and haven’t found anyone else reporting this problem anywhere so it must not be a common issue and must just be something wrong with my set up. I just did a fresh install of the VC++ Express 2010, but that didn’t help. Where do I even start looking?

Have you tried running

haxelib run lime setup windows

This should make sure you’re all set up to compile with c++ targets.

Yes, I did try that already. All that does is downloads and installs Visual Studio C++ Express, but doesn’t make any difference. So it seems like FlashDevelop is missing some connection to it. Is there a path or something that needs to be set somewhere that perhaps wasn’t set right by the install?

You might have to restart in order for the environment variables to populate on your system. Have you tried that yet?

Yep, tried that, didn’t help.

Out of frustration I went through and uninstalled everything and started again. I followed the steps to the letter in the openfl docs and in the haxeflixel docs, but I’m still getting the same error when trying to compile for Windows. Is there a path somewhere in a config file or registry that I can check as FlashDevelop is obviously not seeing the Visual Studio C++ Express install.

Firstly, I wouldn’t recommend using FD’s in-built debugger, it’s not very good :smile:

Instead, I would recommend just building using the command line as that guarantees build safety:

haxelib run openfl build project.xml windows


openfl build project.xml windows

Depending on how you set it up.

At this point I haven’t even thought about debugging yet. Just trying to get it to compile at least first. :blush:

I tried your suggestion and still the same error in the command line.

C:/HaxeToolkit/haxe/lib/hxcpp/3,2,102/src/hx/Date.cpp(6) : fatal error C1083: Cannot open include file: 'windows.h': No such file or directory

Well at least this little test has eliminated FlashDevelop from the equation. So the problem has something to do with openfl or haxe. Which one is actually doing the compiling, is it haxe? Does it have a config file or something like that where the path to the Visual Studio C++ Express install is as I’m guessing that is probably wrong and could be easily fixed if I knew where it is set?

What version of VC++ do you have installed? Does it have Win32 libraries installed?

I have the full Visual Studio 2010 and 2013 installed as I use them for other .Net and C++ work. I installed the Visual Studio C++ Express that it asked me to when I ran the “haxelib setup windows” command. Is there a way I can tell which version of VC++ that OpenFL is linking to?

I believe it uses the newest one, does 2013 have Win32 libraries, or only WinRT libraries? (some of them don’t include desktop Win32 headers and libraries by default)

You can force an older one with a define, like this:

The define value will depend on the VC version you want to force

I solved the problem by installing Visual Studio 2015 and made sure to tick to install the VC++ libraries. Now it compiles and runs great.

1 Like