Important: Please read the Qt Code of Conduct -

"Cannot open include file: windows.h" when compiling example from tutorial.

  • Hi!
    I'm new to Qt, so I decided to start from running some tutorials (from QtCreator).
    I wanted to compile a project from tutorial 2 "Creating a Qt Quick Application Using Qt Quick Components", but ended with the below error message:

    D:\Software\QtSDK\QtCreator\bin\jom.exe -nologo -j 8 -f Makefile.Release
    cl -c -nologo -Zm200 -Zc:wchar_t- -O2 -MD -GR -EHsc -W3 -w34100 -w34189 -DUNICODE -DWIN32 -DQT_LARGEFILE_SUPPORT -DQ_COMPONENTS_SYMBIAN -DHAVE_MOBILITY -DQT_DLL -DQT_NO_DEBUG -DQT_DECLARATIVE_LIB -DQT_GUI_LIB -DQT_NETWORK_LIB -DQT_CORE_LIB -DQT_HAVE_MMX -DQT_HAVE_3DNOW -DQT_HAVE_SSE -DQT_HAVE_MMXEXT -DQT_HAVE_SSE2 -DQT_THREAD_SUPPORT -I"......\Software\QtSDK\Simulator\Qt\msvc2008\include\QtCore" -I"......\Software\QtSDK\Simulator\Qt\msvc2008\include\QtNetwork" -I"......\Software\QtSDK\Simulator\Qt\msvc2008\include\QtGui" -I"......\Software\QtSDK\Simulator\Qt\msvc2008\include\QtDeclarative" -I"......\Software\QtSDK\Simulator\Qt\msvc2008\include" -I"......\Software\QtSDK\Simulator\QtMobility\msvc2008\include\QtSystemInfo" -I"d:\Software\QtSDK\Simulator\QtMobility\msvc2008\include\QtMobilitySimulator" -I"..\Tut1\qmlapplicationviewer" -I"......\Software\QtSDK\Simulator\QtMobility\msvc2008\include" -I"......\Software\QtSDK\Simulator\QtMobility\msvc2008\include\QtMobility" -I"......\Software\QtSDK\Simulator\Qt\msvc2008\include\ActiveQt" -I"release" -I"..\Tut1" -I"." -I"......\Software\QtSDK\Simulator\Qt\msvc2008\mkspecs\win32-msvc2008" -Forelease\ @C:\Users\113010~1\AppData\Local\Temp\qmlapplicationviewer.obj.2328.0.jom
    d:\software\qtsdk\simulator\qt\msvc2008\mkspecs\win32-msvc2008../win32-msvc2005/qplatformdefs.h(67) : fatal error C1083: Cannot open include file: 'windows.h': No such file or directory
    Copying application data...
    2 File(s) copied

    I have no clue how to tell the compiler where to look for windows.h header.

    Thanks for any suggestions.

  • Did you install Visual Studio or Visual Studio Express 2008, or a Windows SDK? Otherwise, you cannot use the MSVC 2008 target. If you want something that works out of the box, use the MinGW target instead.

    You should have received a warning about that in the installer though.

  • Thanks for the answer.

    I have a Professional 2008 and didn't notice any warning during installation. Also Qt Creator seems to recognize it well.
    I wanted to change the tool set from Microsoft Visual C++ Compiler 9.0 (x86) to MinGW (it also appears in the dialog when clicked Manage button), but the combo box is inactive.

    Also sometimes (it probably depends on what example I choose) I encounter linker error: LNK1104: cannot open file 'kernel32.lib' (no such file).

    Don't know what to do.

  • I wanted to do it with Visual Studio, but nothing helped (even reinstalling Windows SDK) :(

    Using MinGW, as you suggested, solved the problem (I had to use SDKMaintenanceTool.exe and add MinGW package to QtSDK installation).


Log in to reply