8

I have a Problem when attempting to compile a simple hello world c++ program.

#include <iostream>

int main()
{
    std::cout << "hello world" << std::endl;
    return 0;
}

Among the errors is:
cannot open source file "errno.h"

A quick search using the console (c:\> dir errno.h /s) reveals that the file is in multiple directories:
C:\LegacyApp\VisualStudio2013\VC\crt\src
C:\LegacyApp\VisualStudio2013\VC\include
C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\crt\src
C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\include
C:\Program Files (x86)\Windows Kits\10\Include\10.0.10150.0\ucrt

My Project Default Properies Include the following macro: $(VC_IncludePath);$(WindowsSDK_IncludePath);

This resolves to:
C:\LegacyApp\VisualStudio2015\VC\include
C:\LegacyApp\VisualStudio2015\VC\atlmfc\include
C:\Program Files (x86)\Windows Kits\10\Include\10.0.10240.0\ucrt
C:\Program Files (x86)\Windows Kits\8.1\Include\um
C:\Program Files (x86)\Windows Kits\8.1\Include\shared
C:\Program Files (x86)\Windows Kits\8.1\Include\winrt

The folder C:\Program Files (x86)\Windows Kits\10\Include\10.0.10240.0\ucrt does not exist on my system.

It seems like I want to switch out the Version 10.0.10240.0 to be 10.0.10150.0

How can I edit the defaults for the macro VC_IncludePath?

Is there an even wiser course of action here?

Johannes
  • 6,490
  • 10
  • 59
  • 108
  • Did you ever work around this issue? I would prefer not to have to re-install VS :( – stk_sfr Dec 09 '16 at 06:55
  • @stk_sfr nope - at the moment the machine in question can not compile c++ with Visual Studio - I will have to reinstall at some point next year. I will add a bounty to this question so maybe someone has a solution. – Johannes Dec 09 '16 at 12:32
  • 1
    I have now hit this problem twice, the first time I re-installed VS. This time I found that "repairing" the installation of "Windows Software Development kit - Windows 10.0.26624" fixed the issue. I did this by selecting "change" via the "programs and features" screen in the control panel (Windows 10). No idea why the version (10.0.26624) listed there does not match the problematic SDK version (10.0.10240.0) – stk_sfr Apr 13 '17 at 02:20
  • I once had this problem with VS2017 and it was resolved by simply restarting VisualStudio. – sartoris Aug 28 '19 at 22:55
  • This problem is still up in VS2022, I have no clue what to do. Repaired VS, reinstalled it, uninstalled all Windows 10 SDK I had, still nothing – Ghosty Frosty Nov 11 '21 at 18:09

2 Answers2

8

Seems installation of Windows 10 SDK version 10.0.10240.0 is broken on your machine. You can reinstall it or use the other version installed on your computer.

If Windows 10 SDK version 10.0.10150.0 installed properly you should be able to use it in your VC++ project. To do that change Target Platform Version on General page of you project configuration to 10.0.10150.0. This value should be among the others in dropdown list.

Otherwise reinstall Windows 10 SDK and use the recently installed version.

Nikita
  • 6,270
  • 2
  • 24
  • 37
  • The link to [link to general](https://msdn.microsoft.com/en-us/library/8x480de8.aspx) is very helpful and clears a lot of things up. I can only set 'Target Platform Version' to '8.1' - so I assume everything is broken and I will have to install again. – Johannes Dec 12 '16 at 12:03
  • @Johannes Typically it means Windows 10 SDK is broken. Try reinstall it first. – Nikita Dec 12 '16 at 12:05
6

Look at Working with Project Properties, particularly the section Property Pages.

There is a similar SO question, How do I modify Visual Studio 2015 predefined macros?, with an answer that says modify the file

C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V140\Microsoft.Cpp.Common.props

but I would first try using the intended properties from the first link.

Community
  • 1
  • 1
Phil
  • 5,822
  • 2
  • 31
  • 60