Troubles with Windows SDK

I recently installed a fresh copy of Visual Studio 2017 on a new machine and went on to build several projects some of them being VC++. The trouble was that I immediately run into a problem (actually the first problem was that MFC & ATL were missing because I forgot to check that in the list of Individual components so I had to install them separately). The problem was an error with a missing new.h header:

1>c:\program files (x86)\microsoft visual studio\2017\enterprise\vc\tools\msvc\14.15.26726\atlmfc\include\afx.h(62): fatal error C1083: Cannot open include file: ‘new.h’: No such file or directory

That happens on compiling the following piece of code in afx.h:

Searching for the new.h header releaved two locations:

But looking at the location of the include directories in Visual C++ (from the expansion of $(VC_IncludePath);$(WindowsSDK_IncludePath);) I’ve seen only these:

None of the actual locations where new.h was present were in this list. That was because I had chosen to install version 10.0.17134.0 of the Windows SDK and no other version. However, my Visual C++ projects were targeting Windows SDK 8.1. It turns out that is in hard-coded in MSBuild that 10.0.10240.0 is used when targeting 8.1. Here is the relevant excerpt from c:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\Common7\IDE\VC\VCTargets\Microsoft.Cpp.Common.props

To solve this there are three possible solution:

  1. Install the required 10.0.17134.0 Windows SDK. To do so, you need to run the Visual Studio Installer, select Individual Components and check it in the list.

    Mind that this SDK requires an additional 3GB of disk space.

  2. Change the targe version from 8.1 to 10.0.17134.0 or whatever else you have installed.

    If you plan to do this and you work in a team with other developers and have dedicated build machines, etc. you need to coordinate so that everybody has the target version of the SDK installed, otherwise the build will run on your machine but not on others.

  3. Manually alter the MSBuild user property files C:\Users\{user}\AppData\Local\Microsoft\MSBuild\v4.0\Microsoft.Cpp.<target>.user.props (where <target> is Win32, x64 and Arm) to overwrite the defaults. These files are initially empty and should look like this:

    You can replace the empty PropertyGroup item with the following (this example is for x86, but you need to do the same with the appropriate paths in all the files):

1 Comment on "Troubles with Windows SDK"

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.