fatal error C1083: Cannot open include file: 'Windows.h': and scons

62,194

Solution 1

Using the above recommendations will not work with scons: scons does not import the user environment (PATH and other variables). The fundamental problem is that scons does not handle recent versions of SDKs/VS .

I am an occasional contributor to scons, and am working on this feature ATM. Hopefully, it will be included soon in scons, but the feature is much harder to implement reliably than I first expected, partly because every sdk/compiler combination is different (and sometimes even MS does not get it right, some of their .bat files are broken), so I can't give you a date. I hope it will be included in 1.2 (to be released in approximatively one month).

Solution 2

You need to set the include file path (and possibly other things). At the command line this is typically done using a batch file that Visual Studio installs called vsvars32.bat (or vcvars32.bat for compatibility with VC6).

I'm not familiar with scons so I don't know the best way to get these settings configured for that tool, but for standard makefiles there's usually a line in the makefile which sets a macro variable with the include directory path and that macro is used as part of a command line parameter in the command that invokes the compiler.

Another possibility might be to have the scons process invoke vsvars32.bat or run the scons script from a command line that has been configured with the batch file.

In short you need to get the things that vsvars32.bat configures into the scons configuration somehow.

Solution 3

There will be a batch file similar to this one (for MSVC 2005) that sets up the environment variables:

c:\Program Files\Microsoft Visual Studio 8\Common7\Tools\vsvars32.bat

Step 1: Find a similar file in the Express installation folders

Step 2: Create a shortcut on the desktop with these target details and a suitably modified path:

cmd.exe /K "c:\Program Files\Microsoft Visual Studio 8\Common7\Tools\vsvars32.bat"

Step 3: Open the DOS prompt via this shortcut

The command line build should now work from within this console window.

Share:
62,194

Related videos on Youtube

OscarRyz
Author by

OscarRyz

Software Developer who happens to like writing code. Here are some interesting answers you might like to upvote :") Why java people frequently consume exception silently ? Coding in Other (Spoken) Languages How to create an string from the contents of a file History of Objective-C square brackets (as I remember it) ( visible only to >10k users )

Updated on February 11, 2020

Comments

  • OscarRyz
    OscarRyz about 4 years

    Today is officially my first day with C++ :P

    I've downloaded Visual C++ 2005 Express Edition and Microsoft Platform SDK for Windows Server 2003 SP1, because I want to get my hands on the open source Enso Project.

    So, after installing scons I went to the console and tried to compile it using scons, but I got this error:

    C:\oreyes\apps\enso\enso-read-only\src\platform\win32\Include\WinSdk.h(64) : fatal error C1083: Cannot open include file: 'Windows.h': No such file or directory
    scons: *** [src\platform\win32\InputManager\AsyncEventProcessorRegistry.obj] Error 2
    scons: building terminated because of errors.
    

    After checking these links:

    VS ans PSDK

    Include tiffi.h

    Wndows.h

    I've managed to configure my installation like this:

    alt text

    And even run this script

    alt text

    And I managed to compile the file below in the IDE.

    // Test.cpp : Defines the entry point for the console application.
    //
    
    #include "stdafx.h"
    #include <Windows.h>
    
    
    int _tmain(int argc, _TCHAR* argv[])
    {
        return 0;
    }
    

    But I still get that exception in the console. Does anyone have scons experience?

    EDIT

    Actually (and I forgot to tell you this) I started the command prompt with the link "Visual Studio 2005 Command Prompt".

    I assume this will include the paths in environment variables. Well after printing them I find that it didn't:

     echo %INCLUDE%
     echo %LIB%
     echo %PATH% 
    

    And they were not present, so I created this .bat file:

    set PATH=%PATH%;"C:\Program Files\Microsoft Platform SDK\Bin"
    set INCLUDE=%INCLUDE%;"C:\ Program Files\Microsoft Platform SDK\Include"
    set LIB=%LIB%;"C:\ Program Files\Microsoft Platform SDK\Lib"
    

    Still, scons seeems not to take the vars... :(

  • Andrew Walker
    Andrew Walker over 15 years
    I can confirm that this is the process that our team normally use when working with SCons on windows.
  • OscarRyz
    OscarRyz over 15 years
    Andrew, can you further explain how do you include vcvars32 in scons?
  • OscarRyz
    OscarRyz over 15 years
    :S How do I manually add the environment variables to scons build process directly?
  • stoic_monk
    stoic_monk over 15 years
    There are two ways. Let say you have the SDK path in the python variable mssdk, you can then add the paths using env.Prepend(CPPPATH, [os.path.join(mssdk, "Include")]) and env.Prepend(LIBPATH, [os.path.join(mssdk, "libpath")])
  • stoic_monk
    stoic_monk over 15 years
    Another way is to simply import the environment into scons: env = Environment(ENV = os.environ). Then, scons will use whatever environment modification you will do in the shell (DOS shell here on windows).
  • OscarRyz
    OscarRyz over 15 years
    Great I did the second and now a different error appears, but not Windows.h thanks a lot!!