First of all: I’m using Microsoft Visual Studio 2012
I am a C#/Java developer and I am now trying to program for the kinect using Microsoft SDK and C++. So I started of with the Color Basics example, and I can not get it to compile.
At first, none of the classes were able to find Windows.h. So I installed (Or re-installed, I’m not sure) the Windows SDK, and added the include dir of the SDK to the include «path» of the project. Then all the problems were gone, except for one:
Error 5 error RC1015: cannot open include file 'windows.h'. C:\temp\ColorBasics-D2D\ColorBasics.rc 17 1 ColorBasics-D2D
And thats the error. No reasons why, the system can find it because it is used in multiple other files, only this file is not able to work with it. As a reference, the entire file that is bugging (ColorBasics.rc):
//------------------------------------------------------------------------------
// <copyright file="ColorBasics-D3D.rc" company="Microsoft">
// Copyright (c) Microsoft Corporation. All rights reserved.
// </copyright>
//------------------------------------------------------------------------------
// Microsoft Visual C++ generated resource script.
//
#include "resource.h"
#define APSTUDIO_READONLY_SYMBOLS
/////////////////////////////////////////////////////////////////////////////
//
// Generated from the TEXTINCLUDE 2 resource.
//
#define APSTUDIO_HIDDEN_SYMBOLS
#include "windows.h"
#undef APSTUDIO_HIDDEN_SYMBOLS
/////////////////////////////////////////////////////////////////////////////
#undef APSTUDIO_READONLY_SYMBOLS
/////////////////////////////////////////////////////////////////////////////
// English (United States) resources
#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)
LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
/////////////////////////////////////////////////////////////////////////////
//
// Icon
//
// Icon with lowest ID value placed first to ensure application icon
// remains consistent on all systems.
IDI_APP ICON "app.ico"
/////////////////////////////////////////////////////////////////////////////
//
// Dialog
//
IDD_APP DIALOGEX 0, 0, 512, 424
STYLE DS_SETFONT | DS_FIXEDSYS | WS_MINIMIZEBOX | WS_CLIPCHILDREN | WS_CAPTION | WS_SYSMENU
EXSTYLE WS_EX_CONTROLPARENT | WS_EX_APPWINDOW
CAPTION "Color Basics"
CLASS "ColorBasicsAppDlgWndClass"
FONT 8, "MS Shell Dlg", 400, 0, 0x1
BEGIN
DEFPUSHBUTTON "Screenshot",IDC_BUTTON_SCREENSHOT,238,391,50,14
CONTROL "",IDC_VIDEOVIEW,"Static",SS_BLACKFRAME,0,0,512,384
LTEXT "Press 'Screenshot' to save a screenshot to your 'My Pictures' directory.",IDC_STATUS,0,413,511,11,SS_SUNKEN,WS_EX_CLIENTEDGE
END
/////////////////////////////////////////////////////////////////////////////
//
// DESIGNINFO
//
#ifdef APSTUDIO_INVOKED
GUIDELINES DESIGNINFO
BEGIN
IDD_APP, DIALOG
BEGIN
END
END
#endif // APSTUDIO_INVOKED
#ifdef APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// TEXTINCLUDE
//
1 TEXTINCLUDE
BEGIN
"resource.h\0"
END
2 TEXTINCLUDE
BEGIN
"#define APSTUDIO_HIDDEN_SYMBOLS\r\n"
"#include ""windows.h""\r\n"
"#undef APSTUDIO_HIDDEN_SYMBOLS\r\n"
"\0"
END
3 TEXTINCLUDE
BEGIN
"\r\n"
"\0"
END
#endif // APSTUDIO_INVOKED
#endif // English (United States) resources
/////////////////////////////////////////////////////////////////////////////
#ifndef APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// Generated from the TEXTINCLUDE 3 resource.
//
/////////////////////////////////////////////////////////////////////////////
#endif // not APSTUDIO_INVOKED
I’m running the latest version of VSCode on Windows 10, build 1803. I’m using C/C++ version 0.17.3. I also have the extensions Dracula and the MIPS Support installed.
When I try to build a windows application on one computer, it builds just fine. However, IntelliSense itself doesn’t tip me in on any WinAPI functions, macros, etc. The odd thing is my other main computer does show the tooltips I’m looking for and it does not have any different (relevent) settings in User settings or workplace settings. (my main computer has its SDKs in a different path but that isn’t reflected in any settings I can find, Intellisense just works)
My user settings for my computer on which Intellisense works:
{
"git.ignoreMissingGitWarning": true,
"C_Cpp.intelliSenseEngineFallback": "Disabled",
"terminal.integrated.shell.windows": "C:\\Windows\\System32\\cmd.exe",
"terminal.integrated.shellArgs.windows": [
"/k",
"C:\\Program Files (x86)\\Microsoft Visual Studio\\2017\\BuildTools\\VC\\Auxiliary\\Build\\vcvars64.bat",
],
"window.zoomLevel": 0,
"editor.insertSpaces": false
}
and on which is doesn’t:
{
"git.ignoreMissingGitWarning": true,
"C_Cpp.intelliSenseEngineFallback": "Disabled",
"terminal.integrated.shell.windows": "C:\\Windows\\System32\\cmd.exe",
"terminal.integrated.shellArgs.windows": [
"/k",
"C:\\Program Files (x86)\\Microsoft Visual Studio 14.0\\VC\\bin\\vcvars32.bat",
],
"window.zoomLevel": 0,
"editor.insertSpaces": false,
"editor.tabCompletion": true,
"editor.detectIndentation": false
}
I’m confused why (but glad) I needed no additional settings to the additional tooltips on my main computer; however, on my side-computer I don’t know what I need to have those tooltips appear as my settings seem the same. All of the macros from the headers have red squiggles and the hover-over tooltip says they’re undefined. (of course because it isn’t finding the windows header) Also, I know where my windows headers are kept on the side-computer:
C:\Program Files (x86)\Windows Kits\10\Include\10.0.14393.0
but I can’t seem to make them found by the extension.
NOTE: all standard library functions (malloc, printf, etc.) detected on both computers, it is only one computer that won’t detect functions anything from windows headers.
Thank you!
Issue
I’m trying to learn DirectX 11 and currently working on lighting. I need to add a Directional light to the scene, but when I set up my LightHelper.h file, it refuses to compile. It throws the error X1507 “failed to open source file: Windows.h”.
I’ve tried uninstalling the Windows SDK and reconfiguring some of the include options to no avail. Here is my code for the header file.
#pragma once
#include <Windows.h>
#include <DirectXMath.h>
struct DirectionalLight
{
DirectionalLight()
{
ZeroMemory(this, sizeof(this));
}
DirectX::XMFLOAT4 Ambient;
DirectX::XMFLOAT4 Diffuse;
DirectX::XMFLOAT4 Specular;
DirectX::XMFLOAT3 Direction;
float Pad;
};
struct Material
{
Material()
{
ZeroMemory(this, sizeof(this));
}
DirectX::XMFLOAT4 Ambient;
DirectX::XMFLOAT4 Diffuse;
DirectX::XMFLOAT4 Specular;
DirectX::XMFLOAT4 Reflect;
};
This isn’t the only header file (of course) with Windows.h, but all of the others link with no issues… I’ve been trying to figure it out for a couple days now. It’s rather annoying.
Thanks
Edit: These are the solutions I tried.
Cannot open Windows.h
https://software.intel.com/en-us/articles/error-cannot-open-source-file-windowsh-in-gfx-sampleszip-shipped-with-intelr-c-compiler-150
I also tried finding the direct file path in “C:\Program Files (x86)\Microsoft SDKs\Windows\v7.1A\Include\”. It just threw another error about not being able to include another header from Windows.h. I think it was “excpt.h”
Solution
With Visual C++ 2015, you are using either the Windows 8.1 SDK (by default) or the Windows 10 SDK. In both cases, you already have DirectXMath, D3DCompile, and other Direct3D headers in your path as well as the FXC
shader compiler as those are in the standard Windows SDKs.
If you need to use legacy components like D3DX11, you can add the legacy DirectX SDK paths but you should do so after the standard paths, not before, in the VC++ Directories properties.
$(VC_IncludePath);$(WindowsSDK_IncludePath);$(DXSDK_DIR)Include
$(VC_LibraryPath_x86);$(WindowsSDK_LibraryPath_x86);$(NETFXKitsDir)Lib\um\x86;$(DXSDK_DIR)Lib\x86
$(VC_LibraryPath_x64);$(WindowsSDK_LibraryPath_x64);$(NETFXKitsDir)Lib\um\x64;$(VC_LibraryPath_x86);$(WindowsSDK_LibraryPath_x86);$(NETFXKitsDir)Lib\um\x86;$(DXSDK_DIR)Lib\x64
See Where is the DirectX SDK? and Where is the DirectX SDK (2015 Edition)?.
Of course, ideally you’d just avoid the legacy DirectX SDK all together. See Living without D3DX
UPDATE: Note if you need D3DX9, D3DX10, and/or D3DX11 only you can also get those headers/libs/DLLS directly from NuGet rather than dealing with the mess of installing/using the legacy DirectX SDK. See this blog post.
Answered By – Chuck Walbourn
This Answer collected from stackoverflow, is licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0
I’m new to C++ and I just got Visual Studio Community 2017. I don’t quite know what workflow to use, so I went with my gut.
When I try to include windows.h
using #include <windows.h>
, I get a squiggly line underneath, and when I hover over, it says
cannot open source file «windows.h»
This is the same with conio.h
and stdio.h
.
I seem to have found the issue
Solved!
-
Click Project (top)
-
Click properties (bottom)
-
Under configuration properties, Click General
-
Under general, click windows SDK version. If it is at
10.x
put it to8.1
then close then put it back to10.x
again.
Seemed to work for me.
Native environment:win10 64Bit vs2017
The method is borrowed from:
I found a code online today, open the display with vs2017
“
Error (active) E1696 Unable to open source file «WinSock2.h» MyServer /*path*/ — copy\main.cpp 2
Error (active) E1696 Unable to open source file «Windows.h» MyServer /*path*/ — copy \main.cpp 3
Error (active) E1696 Unable to open source file «mswsock.h» MyServer /*path*/ — copy \main.cpp 4
Error (active) E1696 Unable to open source file «Ws2tcpip.h» MyServer /*path*/ — copy\main.cpp 8
”
Then I found a long time to solve the problem and finally found it:
1. Right click project -> Properties
2. Change the regular Windows SDK version to the current system SDK version, my is 10.0.17134.0
3. Get it done