none
Clean install of VS2013 fails to build C++ project. Error: Could not find WindowsSDKDir variable from the registry.

    Question

  • I initially installed Visual Studio 2013 Professional on an internet-connected computer and had no problems. Recently, I have had to move to an offline system (still running Windows 7) and had to install everything from scratch.

    Now I am getting the dreaded "Could not find WindowsSdkDir variable from the registry. TargetFrameworkVersion or Platform Toolset may be set to an invalid version number" warning, followed by errors along the lines of "Cannot open 'windows.h': No such file or directory".

    I have spent all day trawling the internet for a solution and it seems that this is quite a common problem, but with no definite fix.

    Following the suggestion here <links not allowed>, I have updated to the latest version (VS2013.5). This made no difference.

    I have tried countless tweaks to the project settings and to Windows registry keys as suggested, for example, here <links not allowed> and here <links not allowed> and here <links not allowed>. However, none of these have worked.

    Looking at the macros in my VS2013 project settings, I can see that $(WindowsSdkDir) does indeed have a blank value, but I simply cannot see how to fix it.

    Any help would be greatly appreciated, as I'm really tearing my hair out over this...

    Wednesday, April 13, 2016 2:21 PM

Answers

  • Do you have any further advice, Hart? I have tried everything you suggested.

    Hi,

    You can open the Microsoft.Cpp.Common.props file and edit these properties, I have tried it  successfully.  Before you edit the file you should backup the file.  There are many version of the Microsoft.Cpp.Common.props.  At the header of the file you will see the keyword(Common properties for v120 toolsets).  So when you open Visual Studio 2015 you should set v120 for the VS, than you will see the properties be changed.

    Best Regards,

    Hart

     



    Thursday, April 21, 2016 8:15 AM
    Moderator

All replies

  • Dear HCommin,

    Welcome to the MSDN forum.

    According to the error message "Could not find WindowsSdkDir variable from the registry. TargetFrameworkVersion or Platform Toolset may be set to an invalid version number", I want to confirm the following message:

    1. Go to registry table and find the folder HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Microsoft SDKs\Windows or HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\Microsoft SDKs\Windows (per your OS is 32 bit or 64 bit), check the keys “InstallationFolder/ProductName/ProductVersion” under V8.1 are point to the right SDK version, please upload the screenshot of the page to https://onedrive.live.com/ and share the link here.

    2. In VS, under Solution Explorer, right-click the project name and select ‘Properties’, go to Configuration Properties-General and set the ‘Platform Toolset’ to point the SDK you want to use, the WindowsSDKdir macro will change appropriately. Remember to make this change for all Configurations and all Platforms.

    What’s more, please have a look at this: http://stackoverflow.com/questions/3599079/windowssdkdir-is-not-set-correctly-in-visual-studio-2010

    Best regards,

    Sara


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.


    Thursday, April 14, 2016 6:12 AM
  • 1. Go to registry table and find the folder HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Microsoft SDKs\Windows or HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\Microsoft SDKs\Windows (per your OS is 32 bit or 64 bit), check the keys “InstallationFolder/ProductName/ProductVersion” under V8.1 are point to the right SDK version.

    Thank you for your reply, Sara.

    This key did not exist after initial installation of VS2013 (or reinstallation, or repairing). So, as indicated in various places around the internet, I understand I need to create it.

    What confuses me about this step is that 7 or 8 instances of the Windows SDK seem to appear (in C:/Program Files (x86)/Microsoft SDKs/Windows and in C:/Program Files (x86)/Windows kits) when VS2013.5 is installed.

    Which one is the right one with respect to the registry key you mention? (I have tried all of them without success so far).



    • Edited by HCommin Thursday, April 14, 2016 8:58 AM
    Thursday, April 14, 2016 8:46 AM
  • Given that it takes a long time to get a response (perhaps we're in different timezones), I'll try and provide some more details.

    Let's assume, for example, that I try to point the registry keys to the v7.1A version of the SDK. (This seems like a reasonable guess, as this is one of only 2 which have >100MB of contents in its installation directory).

    I know you asked me to upload a screenshot, but as I said before, the system is not internet connected and I have no way of taking any data off it. So I'll type out what I wrote for the subkeys:

    InstallationFolder = C:\Program Files (x86)\Microsoft SDKs\Windows\v7.1A\

    ProductName = Microsoft Windows SDK for Windows 7.1A

    ProductVersion = 7.1.51106

    I copied InstallationFolder and ProductVersion from the HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\Microsoft SDKs\Windows\v7.1A key and I just guessed ProductName.

    I go back into Visual Studio 2013 and the "Could not find WindowsSdkDir variable..." warning has gone and the $(WindowsSdkDir) macro correctly points to the SDK v7.1A install directory. Great... except the errors along the lines of "Cannot open include file: 'SDKDDKVer.h...'" still remain, so I'm not sure if I'm any better off than before.

    Please help!

    Thursday, April 14, 2016 1:36 PM
  • Update:

    It seems that the problem is that the following three macros are used without being defined:

    $(WindowsSDK_ExecutablePath)

    $(WindowsSDK_IncludePath)

    $(WindowsSDK_LibraryPath)

    These are used in Project Properties -> Configuration Properties -> VC++ Directories in the "Executable Directories", "Include Directories" and "Library Directories" fields, respectively.

    If I replace these with:

    $(WindowsSdkDir)\Bin

    $(WindowsSdkDir)\Include

    $(WindowsSdkDir)\Lib

    then the project builds and runs.

    I don't want to have to make these changes every time I create a new project, so it would be great if anyone could tell me how to set these macros. Reading around, it seems that this may be possible by modifying C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V120\Microsoft.Cpp.Common.props. Can anyone offer any advice?


    • Edited by HCommin Friday, April 15, 2016 8:10 AM
    Friday, April 15, 2016 8:09 AM
  • Unfortunately, my workaround still leaves the build environment in a broken state outside the GUI (e.g. when building from the command line).

    Having wasted 3 days trying to get Visual Studio to install, I had a go at installing Netbeans with the GCC toolchain under MinGW. That was all completely up and running within 20 minutes, so I'm just going to crack on with that for now.

    If anyone ever does read my messages, I would still be interested in a solution. We paid an enormous sum of money for Visual Studio, so it would be nice to get some use out of it.

    Friday, April 15, 2016 12:06 PM
  • Dear HCommin,

    Thank you for your update and sorry to my later reply.

    I’m so sorry I can’t help you to solve this issue immediately and I will invite higher professional engineer to investigate this issue then help you to solve it.

    Thank you for your understanding.

    Best regards,

    Sara


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Monday, April 18, 2016 2:44 AM
  • Dear HCommin,

    After confirmed with the higher professional engineer and this issue is related with the VC++, and I will help you move it to the VC++ forum: Visual Studio Languages Visual C++ for dedicated information.

    Thank you for your understanding.

    Best regards,

    Sara


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Monday, April 18, 2016 7:04 AM
  • Update:

    It seems that the problem is that the following three macros are used without being defined:

    $(WindowsSDK_ExecutablePath)

    $(WindowsSDK_IncludePath)

    $(WindowsSDK_LibraryPath)

    These are used in Project Properties -> Configuration Properties -> VC++ Directories in the "Executable Directories", "Include Directories" and "Library Directories" fields, respectively.

    If I replace these with:

    $(WindowsSdkDir)\Bin

    $(WindowsSdkDir)\Include

    $(WindowsSdkDir)\Lib

    then the project builds and runs.

    I don't want to have to make these changes every time I create a new project, so it would be great if anyone could tell me how to set these macros. Reading around, it seems that this may be possible by modifying C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V120\Microsoft.Cpp.Common.props. Can anyone offer any advice?


    Hi,

    If you want to know how to reset the WindowsSdkDir variable. You can open the Visual Studio, than open the VC++ directories, than open Library WinRT Directories. At here you can look for the variable than you can reset variable. if you have any question ,please tell me. 

    The attachment is my screenshot.

    Hope reply can help you.

    if you have free time please see the article .how to fix 

    Broken $(WindowsSdkDir) Variable https://helgeklein.com/blog/2010/01/visual-studio-fixing-broken-windowssdkdir-variable/

    Best Regards,

    Hart


    Monday, April 18, 2016 7:18 AM
    Moderator
  • If you want to know how to reset the WindowsSdkDir variable. You can open the Visual Studio, than open the VC++ directories, than open Library WinRT Directories. At here you can look for the variable than you can reset variable. if you have any question ,please tell me.

    Thanks for your reply, Hart.

    This does not work for me. I can view the macros, but I cannot set them.

    I am very familiar with the article you linked to. As I said in my previous post, that method does not work for me (it removes the warning, but not the errors).

    • Edited by HCommin Monday, April 18, 2016 5:08 PM
    Monday, April 18, 2016 5:06 PM
  • Do you have any further advice, Hart? I have tried everything you suggested.
    Thursday, April 21, 2016 7:08 AM
  • Do you have any further advice, Hart? I have tried everything you suggested.

    Hi,

    You can open the Microsoft.Cpp.Common.props file and edit these properties, I have tried it  successfully.  Before you edit the file you should backup the file.  There are many version of the Microsoft.Cpp.Common.props.  At the header of the file you will see the keyword(Common properties for v120 toolsets).  So when you open Visual Studio 2015 you should set v120 for the VS, than you will see the properties be changed.

    Best Regards,

    Hart

     



    Thursday, April 21, 2016 8:15 AM
    Moderator