Cannot open source file windows h

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 examp...

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:tempColorBasics-D2DColorBasics.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"
END

2 TEXTINCLUDE 
BEGIN
    "#define APSTUDIO_HIDDEN_SYMBOLSrn"
    "#include ""windows.h""rn"
    "#undef APSTUDIO_HIDDEN_SYMBOLSrn"
    ""
END

3 TEXTINCLUDE 
BEGIN
    "rn"
    ""
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 Kits10Include10.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!

  • Remove From My Forums
  • Question

  • WOW, I can’t believe this information isn’t easier to find.  I downloaded and installed Visual C++ 2005 Express, and then downloaded and installed the Platform SDK SP2.  NOTHING WORKS!  The Directories are not found and there is no apparent way to set them.  Apparently users have found a hack to make it work, but this is crazy.  It seems like the first Microsoft person to install this would notice that it doesn’t work and would raise the flag to the appropriate people so they can take the steps to fix it for their users.  Or at least document it on the very first page where it is downloaded, or the very first page of the documentation.  A user shouldn’t have to hit forums to find out how to make a product work.
    Sorry, I’m not usually one to complain, and I am a big fan of Microsoft.  I guess I’m just hoping they will fix this or let us know what happened. 
    I don’t understand why I have to copy those directories and why I can’t just correct whatever file is pointing to them.  I went to those weird config files and changed them to point to my directories, but it still cannot find windows.h.  Any ideas?

    John

Answers

  •  This article describes what you need to do to build Win32 applications using Visual C++ Express and the Windows SDK for Windows Server 2008 and .NET Framework 3.5.  A more detailed explanation including screenshots can be found here.

    With the Visual Studio 2008 Express versions you can build Win32 applications right out of the box.  You no longer have to manually integrate the Windows SDK content with VC++ Express.

    The Visual Studio 2008 editions are seamlessly integrated with the Windows SDK.  VS2008 editions include the same Vista RTM headers and libraries that shipped in the Microsoft Windows  Software Development Kit Update for Windows Vista released in March, 2007. The SDK tools included with VS2008 editions are more recent than those that ship in the Vista Update SDK and the Windows Server 2003 Platform SDK.

    If you install another SDK, such as the Windows SDK for Windows Server 2008 and .NET Framework 3.5 after you install VS, you are ready to develop with the headers, libraries and tools in the SDK for Windows Server 2008.  Read on if you installed the SDK before installing Visual Studio.  (It’s easy to switch back if you want.) 

    Here’s how:

    Step 1: Install Microsoft Visual C++ 2008 Express.

    Step 2: Install the Windows SDK for Windows Server 2008 and .NET Framework 3.5.

    You’re done.  After installing the Server 2008 SDK, the registry key is set to point to the new Server 2008 SDK (v6.1) content.  If you installed the Windows Server 2008 SDK before you install Visual Studio, you will need to use the SDK Configuration Tool to set the directories.  If you want to switch back to the default (Vista v6.0A) headers and libraries that were installed with VS 2008, you should use the new SDK Configuration Tool to select the v6.0A SDK content.

    Step 3: Use the SDK Configuration Tool to update the Visual C++ directories

    The Windows SDK for Windows Server 2008 includes a new SDK Configuration Tool that sets the Visual Studio include, library and tools directories for you.  This tool allows you to switch quickly between the headers, libraries and tools in the installed Windows SDK(s) and those that are embedded in Visual Studio.  If you install the Windows Server 2008 SDK before you install Visual Studio, you will need to use the SDK Configuration Tool to set the directories manually.

     The SDK Configuration Tool has a GUI interface but it works only on the Visual Studio Retail (non-Express) SKUs.  (This is scheduled be fixed in the next release.) You will use the SDK Configuration tool at the command line with VC++ Express.

    1.       Launch the Windows SDK Command Window (Start, All Programs, Microsoft Windows SDK v6.1, Command Window)

    2.       CD to Program FilesMicrosoftWindowsv6.1Setup>

    3.       Type:  WindowsSdkVer.exe -version:v6.1

    This command will set the Windows SDK for Windows Server 2008 (v 6.1) as the “current” SDK for Visual Studio to use for headers, libraries and tools.  Use ‘-version:v6.1’ for the Windows Server 2008 SDK content.  Use ‘-version:v6.0A’ for the Visual Studio 2008 content. 

    Step 4: Validate that the directories were updated.

    Open the VC++ Express command window and check the PATH to see if the v6.1 directory has been added.

    How to switch directories back to the SDK content that shipped ‘in the box’ with VC++ 2008 Express

    Use the SDK Configuration Tool at the command line to make v6.0A the current version.

    Karin Meier

    Windows SDK Program Manager

    This posting is provided “AS IS” with no warranties, and confers no rights.

    send feedback to wsdkfb@microsoft.com

  • The are a couple of things that you need to remember about the Express Edition:

    1) It is a starter product: the «typical» customer we foresee for the Visual C++ Express Edition is a student who is interested in learning C++.

    2) It is a product that you download: therefore even in these days of broadband we needed to keep down the size of the product.

    Combine these two statements and you see why we didn’t include the Platform SDK — it was just too big. As Ayman, and many other people, have pointed out you can, if you really want the PSDK, then you can download it separately. While there were issues with the integration of the PSDK with the Beta-2 release of the Visual C++ Express Edition these have been fixed with the final Whidbey release.

Цитата
Сообщение от ATAMAN200
Посмотреть сообщение

наскоко мне память не изменяет Visul C++ 2005 Express Editional это не полная версия просто в ней отсутствует инклуд windows.h
Добавлено через 2 минуты
для полной разработки приложений тебе надо Visul C++ 2005 Profissional Editional

Да ну?!!

MACCOP, создаёте новый проект, выбираете «консольное приложение Win 32», обзываете его как-нибудь (к примеру HelloMessage), жмёте кнопку «готово» — в редактор загружается файл HelloMessage.cpp примерно такого содержания:

C++
1
2
3
4
5
6
7
8
9
10
// HelloMessage.cpp: определяет точку входа для консольного приложения.
//
 
#include "stdafx.h"
 
 
int _tmain(int argc, _TCHAR* argv[])
{
    return 0;
}

слева от него есть окно «обозреватель решений», в котором в папке «заголовочные файлы» значится stdafx.h — щёлкаете по нему два раза — он загружается в редактор и вот там добавляете windows.h

C++
1
2
3
4
5
6
7
8
9
10
11
12
13
14
// stdafx.h: включаемый файл для стандартных системных включаемых файлов
// или включаемых файлов для конкретного проекта, которые часто используются, но
// не часто изменяются
//
 
#pragma once
 
#include "targetver.h"
 
#include <stdio.h>
#include <tchar.h>
 
// TODO: Установите здесь ссылки на дополнительные заголовки, требующиеся для программы
#include <Windows.h>

после чего в HelloMessage.cpp перед return 0; вставляете строку

C++
1
MessageBoxA(NULL, "Hello world!", "Greeting", MB_OK);

запускаете, наблюдаете вот такую картинку
Название: hello.png
Просмотров: 2355

Размер: 2.5 Кб

Прежде всего: я использую Microsoft Visual Studio 2012

Я разработчик на C # / Java и сейчас пытаюсь программировать для kinect, используя Microsoft SDK и C ++. Итак, я начал с примера Основы цвета, и я не могу заставить его скомпилировать.
Сначала ни один из классов не смог найти Windows.h. Поэтому я установил (или переустановил, я не уверен) Windows SDK и добавил каталог включения SDK во включаемый «путь» проекта. Тогда все проблемы исчезли, кроме одной:

Error   5   error RC1015: cannot open include file 'windows.h'. C:tempColorBasics-D2DColorBasics.rc  17  1   ColorBasics-D2D

И это ошибка. Нет причин, по которым система может найти его, потому что он используется в нескольких других файлах, только этот файл не может с ним работать. В качестве ссылки, весь файл, который содержит ошибки (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"END

2 TEXTINCLUDE
BEGIN
"#define APSTUDIO_HIDDEN_SYMBOLSrn""#include ""windows.h""rn""#undef APSTUDIO_HIDDEN_SYMBOLSrn"""END

3 TEXTINCLUDE
BEGIN
"rn"""END

#endif    // APSTUDIO_INVOKED

#endif    // English (United States) resources
/////////////////////////////////////////////////////////////////////////////#ifndef APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// Generated from the TEXTINCLUDE 3 resource.
///////////////////////////////////////////////////////////////////////////////
#endif    // not APSTUDIO_INVOKED

29

Решение

Если вы этого еще не сделали, попробуйте добавить "SDK PathInclude" чтобы:

Project → Preferences → C/C++ → General → Additional Include Directories

И добавить "SDK PathLib" чтобы:

Project → Preferences → Linker → General → Additional Library Directories

Также попробуйте поменять "Windows.h" в <windows.h>

Если это не поможет, проверьте физическое существование файла, он должен находиться в папке « VC PlatformSDK Include» в каталоге установки Visual Studio.

21

Другие решения

Если вы ориентируетесь на Windows XP (v140_xp), попробуйте установить Поддержка Windows XP для C ++.

Начиная с Visual Studio 2012, набор инструментов по умолчанию (v110) прекратил поддержку Windows XP. В результате Windows.h ошибка может возникнуть, если ваш проект ориентирован на Windows XP с пакетами C ++ по умолчанию.

Проверьте, какая версия Windows SDK указана в вашем проекте Набор инструментов платформы. (Project → Properties → Configuration Properties → General). Если ваш Toolset заканчивается _xpВам нужно будет установить поддержку XP.

Visual Studio: набор инструментов проекта

Откройте установщик Visual Studio и нажмите изменять для вашей версии Visual Studio. Открой Отдельные компоненты вкладка и прокрутите вниз до Компиляторы, инструменты сборки и среды выполнения. Около дна, проверьте Поддержка Windows XP для C ++ и нажмите изменять начать установку.

Установщик Visual Studio: поддержка XP для C ++

Смотрите также:

  • Как ориентироваться на Windows XP в Microsoft Visual Studio C ++
  • В чем разница между наборами инструментов платформы v140 и v140_xp?

2

Я получил эту ошибку фатальная ошибка lnk1104: не могу открыть файл ‘kernel32.lib’. эта ошибка возникает из-за отсутствия пути в каталогах VC ++. Для решения этой проблемы

Откройте Visual Studio 2008

  1. перейдите в каталог Tools-options-Projects and Solutions-VC ++- *
  2. затем в правом углу выберите Библиотека файлов
  3. здесь вам нужно добавить путь к kernel132.lib

В моем случае это C: Program Files Microsoft SDKs Windows v6.0A Lib

-1

Why do I get the error «Cannot open source file: ‘windows.h'» when trying to compile a model Simulink (R2013a)?

Sameer

Hello Users,

I am facing an issue while Compiling my Simulink Model containing ASCII Encode block.

(F) C0005; «C:PROGRA~1MATLAB~1toolboxrtwtargetsxpctargetbuildxpcblocksasciiencode.c», line 20 pos 21; could not open source file «windows.h» #include windows.h ^

I am not familiar with this situation. Can anyone please help me with this?

Best Regards


Answers (0)

See Also

Categories

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

An Error Occurred

Unable to complete the action because of changes made to the page. Reload the page to see its updated state.

  • Home
  • Forum
  • Community Boards
  • Tech Board
  • #include <windows.h> not working…

  1. 08-26-2006


    #1

    mkylman is offline


    Registered User


    Unhappy #include <windows.h> not working…

    I am trying out some of the more advanced tutorials, which are way over my head; There’s probably the first sign of a problem right there ;-) But anyway, I gave up on that, and then downloaded the source code for the calculator program; I opened up microsoft visual c++ 2005 express, and then opened up the project file that came with the source code I downloaded; I hit ctrl+shift+b to build/compile the project and it returned an error to me, saying that it couldn’t use «windows.h» because there was no such file in the directory;

    Here is what it says in the output window(this is the error message)

    —— Build started: Project: Calc, Configuration: Debug Win32 ——
    Compiling…
    calc.cpp
    c:documents and settingsmikedesktopcalcglobal.h(5) : fatal error C1083: Cannot open include file: ‘windows.h’: No such file or directory
    Build log was saved at «file://c:Documents and SettingsMikeDesktopCalcDebugBuildLog.htm»
    Calc — 1 error(s), 0 warning(s)
    ========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

    What does this mean exactly? Does anyone else have this problem? Does anyone know how to fix this problem? Thanks in advance;


  2. 08-26-2006


    #2

    Raigne is offline


    Registered User


    are you including it like

    Code:

    #include "windows.h"

    cause that would be wrong

    Code:

    #include <windows.h>

    would be the correct way, if that isnt the problem I don not know , but according to teh errors that looks like what it is


  3. 08-26-2006


    #3

    JaWiB is offline


    carry on

    JaWiB's Avatar


    «Think not but that I know these things; or think
    I know them not: not therefore am I short
    Of knowing what I ought.»
    -John Milton, Paradise Regained (1671)

    «Work hard and it might happen.»
    -XSquared


  4. 08-26-2006


    #4

    mkylman is offline


    Registered User


    oh, I didn’t know this had to do with compiler configuration…I’m sorry :-(


  5. 08-26-2006


    #5

    mkylman is offline


    Registered User


    Thanks guys! Oh, Raigne, I am using it inside the < > brackets, that’s just how the output looked…And thanks Jawib, I’ll definitely look there


  6. 08-27-2006


    #6

    Salem is offline


    and the hat of int overfl

    Salem's Avatar


    http://cboard.cprogramming.com/showthread.php?t=82085
    There are a lot of threads, one has been merged and this one is closed.


Popular pages

  • Exactly how to get started with C++ (or C) today
  • C Tutorial
  • C++ Tutorial
  • 5 ways you can learn to program faster
  • The 5 Most Common Problems New Programmers Face
  • How to set up a compiler
  • 8 Common programming Mistakes
  • What is C++11?
  • Creating a game, from start to finish

Recent additions subscribe to a feed

  • How to create a shared library on Linux with GCC — December 30, 2011
  • Enum classes and nullptr in C++11 — November 27, 2011
  • Learn about The Hash Table — November 20, 2011
  • Rvalue References and Move Semantics in C++11 — November 13, 2011
  • C and C++ for Java Programmers — November 5, 2011
  • A Gentle Introduction to C++ IO Streams — October 10, 2011

Similar Threads

  1. Replies: 7

    Last Post: 04-26-2008, 12:46 AM

  2. Replies: 6

    Last Post: 02-09-2008, 05:26 AM

  3. Replies: 5

    Last Post: 05-21-2006, 11:23 PM

  4. Replies: 7

    Last Post: 10-03-2003, 04:25 AM

  5. Replies: 12

    Last Post: 08-05-2002, 05:38 PM

Понравилась статья? Поделить с друзьями:
  • Cannot open hasp driver windows server 2012
  • Cannot open file c windows system32 drivers etc hosts bandicam
  • Cannot locate the microsoft visual foxpro support library windows 10
  • Cannot init d3d or grf file has problem ragnarok windows
  • Cannot get adapter config hamachi windows 10