compiler cannot find windows.h

I tried to compile an existing program (which I want to modify). The
program is written in C++. So I downloaded Microsoft's Visual C++
Express edition and I tried to compile the program. It failed to
compile, and the error I got was that "windows.h" could not be found.
I did a search in my computer for windows.h, and it was in the Microsoft Platform SDK\include directory and I looked at my compiler 'directories' menu option and saw that I had added that directory. Furthermore I had modified various files that the compiler uses as specified in msdn instructions. But still the compiler cannot find Windows.h.

Here's the error message:
------ Build started: Project: FullDuplexFilter, Configuration: Debug
Win32 ------
Compiling...
dxstdafx.cpp
c:\dirxsdk\samples\c++\common\dxstdafx.h(43) : fatal error C1083:
Cannot open include file: 'windows.h': No such file or directory
Build log was saved at
"file://c:\dirxsdk\Samples\C++\DirectSound\FullDuplexFilter\Debug\BuildLog.-htm"
FullDuplexFilter - 1 error(s), 0 warning(s)
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped
==========

searchstring: Blackdog visual



Answer this question

compiler cannot find windows.h

  • jfalberg

    Orang Pemalong.

    Some of those samples you can compile, the others (mostly the ATL/MFC samples) you won't be able to compile. Which sample are you having trouble with



  • aboreham

    BLACKDOG2 wrote:

    I tried to compile an existing program (which I want to modify). The
    program is written in C++. So I downloaded Microsoft's Visual C++
    Express edition and I tried to compile the program. It failed to
    compile, and the error I got was that "windows.h" could not be found.
    I did a search in my computer for windows.h, and it was in the Microsoft Platform SDK\include directory and I looked at my compiler 'directories' menu option and saw that I had added that directory. Furthermore I had modified various files that the compiler uses as specified in msdn instructions. But still the compiler cannot find Windows.h.

    Here's the error message:
    ------ Build started: Project: FullDuplexFilter, Configuration: Debug
    Win32 ------
    Compiling...
    dxstdafx.cpp
    c:\dirxsdk\samples\c++\common\dxstdafx.h(43) : fatal error C1083:
    Cannot open include file: 'windows.h': No such file or directory
    Build log was saved at
    "file://c:\dirxsdk\Samples\C++\DirectSound\FullDuplexFilter\Debug\BuildLog.-htm"
    FullDuplexFilter - 1 error(s), 0 warning(s)
    ========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped
    ==========

    searchstring: Blackdog visual

    I'm assuming you followed the video available in the VCExpress site.

    Is the PlatformSDK include directory present in the list when you do: Tools-> Options-> Projects and Solutions-> VC++ Directories-> Show directories for: Include files

    (Important: that last step was not performed in the video, it was a mistake made in the video that Microsoft have yet to correct).

    As an alternative to fiddling with the include directories, you may be reinstall (that's uninstall then reinstall) the Platform SDK from C:\Program Files\Microsoft Platform SDK to:

    C:\Program Files\Microsoft Visual Studio 8\VC\PlatformSDK



  • kharulli

    I got like this:

    Compiling...
    stdafx.cpp
    C:\Program Files\Microsoft Platform SDK for Windows Server 2003 R2\Include\mfc\afxwin.h(1227) : fatal error C1083: Cannot open include file: 'afxmsg_.h': No such file or directory
    Build log was saved at "file://c:\Documents and Settings\Orang Pemalang\My Documents\Visual Studio 2005\Projects\button\Debug\BuildLog.htm"
    button - 1 error(s), 0 warning(s)
    ========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

    I cant find '
    afxmsg_.h' in my computer. Help me, please...

  • Suresh C

    Jim Baerg, Have you followed all the steps detailed in http://msdn.microsoft.com/vstudio/express/visualc/usingpsdk/default.aspx. Note, that the PSDK link given in step 2 links to an outdated version of the PSDK... use this link instead for a later version (or if you think you're ready... this link).



  • Flip

    Guys, I think I may have stumbled across the more general problem with Express. MS's Brian Johnson explained (Here: http://lab.msdn.microsoft.com/express/visualc/usingpsdk/default.aspx ) in this statement: "You can use Visual C++ 2005 Express to build powerful .NET Framework applications immediately after installation. In order to use Visual C++ Express to build Win32 applications, you'll need to take just a few more steps."..., then he continues on to describe how to fix the problem. Try it! It works!
  • robinsenior

    Visual C++ Express Edition does not support MFC development - if you want to do MFC (or ATL) development you need to get at least the Standard Edition.

  • J. Shen

    Did you get solution for this I am getting same error when I try to migrate a project form MFC C++ 6.0 to Visual C++ 2005. How to get ride off this Should I use a different header file to replace afxwin.h

    Any suggestions would be appreciated.


  • Steve Boyd

    I ran into the same problem as BLACKDOG2.

    I was using a set of functions CreateFile, WriteFile, etc. since they allow me to read & write data in files larger than 2 or 4 GB. Ie: they use 64 rather than 32 bit addressing.

    Are there other functions that allow me to do that which don't require windows.h If so are there any advantages to those functions over the ones I was using

    Also I want to write a DLL containing functions in C that can be called from a Visual Basic routine, & these functions would use WriteFile etc. Does Visual Basic have any problems with those windows.h functions


  • gotit

    well, in fact i got the same issue :

    >C:\Program Files\Microsoft Platform SDK for Windows Server 2003 R2\Include\mfc\afxwin.h(1227) : fatal error C1083: Cannot open include file: 'afxmsg_.h': No such file or directory

    and afxmsg_.h is nowhere to be found on my computer.

    Did you manage to solve this problem



  • Mweimer

    So.... Can't i compile "Visual C++ Sample Applications" in http://msdn2.microsoft.com/en-us/library/1370z17c.aspx I use latest PSDK and try http://msdn.microsoft.com/vstudio/express/visualc/usingpsdk/default.aspx steps. .

  • compiler cannot find windows.h