A: 

You show us how you configured Visual Studio for compilations within Visual Studio but you didn't show us what command line environment you tried. Sorry I haven't tried Express versions so I don't know if they create additional Start menu shortcuts like Pro and above do. If you open a suitable command prompt with its environment variables already set then you can compile on the command line. Otherwise you have to set variables yourself or execute a batch script to set them, each time you open a command prompt.

Windows programmer
+1  A: 

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.

Michael Burr
I can confirm that this is the process that our team normally use when working with SCons on windows.
Andrew Walker
Andrew, can you further explain how do you include vcvars32 in scons?
OscarRyz
A: 

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.

jussij
+3  A: 

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).

David Cournapeau
:S How do I manually add the environment variables to scons build process directly?
OscarRyz
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")])
David Cournapeau
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).
David Cournapeau
Great I did the second and now a different error appears, but not Windows.h thanks a lot!!
OscarRyz
A: 

I have this same problem, where a build using scons fails to find windows.h. I did run vsvars32.bat in the commands prompt, and windows.h still cannot be found. I always have these problems trying to compile C or C++ projects. It's great that Microsoft tries to abstract away alot of this stuff, and they've eliminated alot of these problems in regards to .NET languages, but C++ is still a pain for me. It's so abstracted away I don't know what's using MS app.config files, or environment variables. I wish it'd just literally tell us "Searching X:\path\" and tell us exactly where it has looked and what logic was used to decide to look there. Most guides regarding this problem reference the platform sdk as being under C:\Program files\Microsoft Platform SDK\, but instead mine, which I installed just last week, is in a different location under "Microsoft SDKs" with about 4 different versions in there. Somebody at MS decided, "hey let's move this stuff around and see who's development environments we can break in the process and render all our previous documentation inaccurate!"

A: 

Oscar, can you please describe in more detail what you did to resolve this. I'm not quite following the suggestions in the first set of comments, as I'm not really familier with scons, and am just trying to get an open source project to compile for the first time.

A: 

It'll be nice when scons does this automatically. For now, I use this (run from an SDK command prompt, not sure if there is a difference if run after vsvars32.bat):

import os
env = Environment(ENV={'PATH': os.environ['PATH']})

env['ENV']['TMP'] = os.environ['TMP']
env.AppendUnique(CPPPATH=os.environ['INCLUDE'].split(';'))
env.AppendUnique(LIBPATH=os.environ['LIB'].split(';'))
A: 

This works for me while compiling wxwidgets with visual c++ 2005 express using the command line prompt

REM Fix Error error C1083 'windows.h' (use /useenv option when compiling)

set PDSKWIN=C:\Program Files\Microsoft Platform SDK for Windows Server 2003 R2 (Change to right one)

set INCLUDE=%PDSKWIN%\Include;%INCLUDE%

set LIB=%PDSKWIN%\Lib;%LIB%

Then I use this line when compile but I just belive just add /useenv to yours lines and everything works fine vcbuild /useenv /nohtmllog /nologo name.proj (or any file to compile)

A: 

BLAHHHHHHHHHHHHHHHHHHH!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

daley
A: 

Yes Xiul worked fine for me for build boost library which game me the same error

deshan