2
votes

I'm trying to build boost on windows 7 64-bits. Running bootstrap gives

execnt.c(29) : fatal error C1083: Cannot open include file: 'windows.h': No such file or directory

and some others. I have visual studio 9.0 and the places where I have windows.h is in

  • C:\Program Files (x86)\Microsoft SDKs\Windows\v5.0\Include**W**indows.h, with capital W
  • C:\Program Files\Microsoft SDKs\Windows\v6.0A\Include**W**indows.h
  • C:\Program Files (x86)\Microsoft Visual Studio 9.0\SmartDevices\SDK\Smartphone2003\Include\windows.h

I have the SDK installed and even fully reinstalled Visual studio. Any way I can fix this?

  • Small update: I installed Visual C++ 2010 express and from the IDE I can include and the test project compiles just fine, but when I use the prompt NO projects can find the header
3
You may get better help on the boost mailing list.Yakov Galka
have you tried to set the include directory?Karoly Horvath
@Karoly Horvath no, how do I do that? I'm not building from inside visual studio, I'm using their bat scriptibrabeicker
The include directory is surely already set from within the IDE. The difference is that those settings aren't incorporated in to the environment that is being used to build Boost. The trick is to get the VS IDE environment variables in the command shell you're using, and that's what the "Visual Studio x64 Win64 Command Prompt (2010)" is for. See @Crazy Eddie's answer.John Dibling

3 Answers

5
votes

Try running the boost build from a VS console rather than trying to run 'cmd'. It's probably somewhere in the start menu entry for VS (used to be anyway). It used to also be available from VS itself under tools, but I think they removed it there.

This version is just cmd, but it runs a batch script that sets a bunch of very important environment variables.

2
votes

For future reference of anyone looking for the same error

I have installed visual studio without registry edition permission, so I had none of the environment variables set, those that boost libraries / libxml2 et al look for when calling the cl compiler

Giving myself permission to edit the registry and uninstalling/reinstalling all visual studio related programs solved it

0
votes

Edit %VS90COMNTOOLS%vsvars32.bat with administrator privileges any way you like, eg.

runas /user:Administrator "notepad %VS90COMNTOOLS%vsvars32.bat"

Find the section

:GetWindowsSdkDirHelper
@for /F "tokens=1,2*" %%i in ('reg query "%1\SOFTWARE\Microsoft\Microsoft SDKs\Windows" /v "CurrentInstallFolder"') DO (
    if "%%i"=="CurrentInstallFolder" (

Change it to

:GetWindowsSdkDirHelper
@for /F "tokens=1,2*" %%i in ('reg query "%1\SOFTWARE\Microsoft\Microsoft SDKs\Windows\v6.0a" /v "InstallationFolder"') DO (
    if "%%i"=="InstallationFolder" (

When you install a newer version of the Windows SDK, it updates HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Microsoft SDKs\Windows\CurrentInstallFolder to point to the newer version.

Unfortunately, the batch file that Visual Studio 2008 uses to set its paths uses this registry key to identify the location of the Windows SDK, so instead of pointing at the version of the Windows SDK that works with VS2008 (6.0a), it points to the the latest version to be installed.

Editing the registry is one option. A better option is to change the batch file so that it gets the right path from the registry, as above.