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 am new to C and I am trying to compile a code that uses am external library. Therefore, I am following these steps for linking a library. But at the very first one
gcc -c -Wall -Werror -fpic PICASO_SERIAL_4DLIBRARY.C
I get this
PICASO_SERIAL_4DLIBRARY.C:1:0: error: -fpic ignored for target (all code is position independent) [-Werror]
#include <windows.h>
cc1plus.exe: all warning being treated as errors
additionally undder # there is a arrow above. I tried googling it but I could only find out that this is a Linux problem and not a Windows one (I am developing on Windows now) and the I followed these steps to install gcc. an compiling other small projects work, too.
Anyone any idea, why this doesn’t work?
![]()
DavidPostill
7,5919 gold badges40 silver badges59 bronze badges
asked Oct 18, 2015 at 7:15
6
The mention of #include <windows.h> is incidental. That just happens to be the first line of code.
The compiler tries to associate a line of code with the error to help you find the problem. But in this case the code is irrelevant. The error is in the command line and you will get a failure no matter what the code is. But because the compiler is coded to always associate a line of code with an error, it decides, arbitrarily, to point the finger at the first line of code.
Because you use -Werror, warnings are treated as errors. The compiler therefore converts a warning about an ignored option to emit position independent code into an error. The error message states this very clearly:
PICASO_SERIAL_4DLIBRARY.C:1:0: error: -fpic ignored for target (all code is position independent) [-Werror]
I suspect you glazed over when reading the error message, and turned your attention to the line of code that was highlighted. Always read error messages carefully!
To resolve the error, remove the -fpic option from your command line.
answered Oct 18, 2015 at 7:30
![]()
David HeffernanDavid Heffernan
595k42 gold badges1052 silver badges1470 bronze badges
3
Try to compile without -fpic. This flag is inappropriate for the mingw-w64 target.
answered Oct 18, 2015 at 7:22
0
I am new to C and I am trying to compile a code that uses am external library. Therefore, I am following these steps for linking a library. But at the very first one
gcc -c -Wall -Werror -fpic PICASO_SERIAL_4DLIBRARY.C
I get this
PICASO_SERIAL_4DLIBRARY.C:1:0: error: -fpic ignored for target (all code is position independent) [-Werror]
#include <windows.h>
cc1plus.exe: all warning being treated as errors
additionally undder # there is a arrow above. I tried googling it but I could only find out that this is a Linux problem and not a Windows one (I am developing on Windows now) and the I followed these steps to install gcc. an compiling other small projects work, too.
Anyone any idea, why this doesn’t work?
![]()
DavidPostill
7,5919 gold badges40 silver badges59 bronze badges
asked Oct 18, 2015 at 7:15
6
The mention of #include <windows.h> is incidental. That just happens to be the first line of code.
The compiler tries to associate a line of code with the error to help you find the problem. But in this case the code is irrelevant. The error is in the command line and you will get a failure no matter what the code is. But because the compiler is coded to always associate a line of code with an error, it decides, arbitrarily, to point the finger at the first line of code.
Because you use -Werror, warnings are treated as errors. The compiler therefore converts a warning about an ignored option to emit position independent code into an error. The error message states this very clearly:
PICASO_SERIAL_4DLIBRARY.C:1:0: error: -fpic ignored for target (all code is position independent) [-Werror]
I suspect you glazed over when reading the error message, and turned your attention to the line of code that was highlighted. Always read error messages carefully!
To resolve the error, remove the -fpic option from your command line.
answered Oct 18, 2015 at 7:30
![]()
David HeffernanDavid Heffernan
595k42 gold badges1052 silver badges1470 bronze badges
3
Try to compile without -fpic. This flag is inappropriate for the mingw-w64 target.
answered Oct 18, 2015 at 7:22
0
See more:
Hi,
In my project after including some header files,it is showing the below error.When I removed those statements it is showing a bulk error of ‘178’ numbers.And I checked which are those including files.Can anyone help me how can I remove that error.
#ifdef _WINDOWS_ #error WINDOWS.H already included. MFC apps must not #include <windows.h> #endif
Thanks,
This may help someone. I got the same error from a UnitTest project.
I changed my stdafx.h to this:
#include "targetver.h" #include <afx.h> #include <afxwin.h> // MFC core and standard components // Headers for CppUnitTest #include "CppUnitTest.h" // TODO: reference additional headers your program requires here
… and the error went.
Here are some of the rules I use for #include files which might be helpful to you:
— Use precompiled headers («#include <stdafx.h>»). This must be the first include in your .cpp file. It should never be in a .h file. [I also routinely rename the file to something project specific (eg. util_stdafx.h) in a multi-project environment so that the wrong file is not included somewhere. You can choose whether or not to do this…]
— Immediately after the stdafx.h file include should be the #include corresponding to your .cpp file. This way, the .h file will #include anything it needs to work properly.
— After these 2 includes in your .cpp file, include anything else needed for the .cpp file to run correctly.
— Header files that come with the compiler are called «Stable headers». These should be the only ones that appear in stdafx.h, along with #defines used by these headers (eg. WIN32_LEAN_AND_MEAN, _WIN32_WINNT etc.). If you are on windows, then stdafx.h is the only place you should see «#include <windows.h>»
— The first non-blank non-comment lines in header files should be either «#pragma once» or guard block definition (or both).
Check probably `Windows.h` might be included in your `stdafx.h` file. If so, then comment `Windows.h` and then check, the error may go off. Because I had the same problem I resolve in same way.
thanks from all of you
your solutions were good and applicational.
i solved it through the following method:
just add below precompile definitions :
#ifdef __windows__ #undef __windows__ #endif
and thanks again
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)
CodeProject,
20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8
+1 (416) 849-8900
Содержание
- Не удается открыть Windows.h в Microsoft Visual Studio
- Решение
- Другие решения
- Смотрите также:
- Не удается открыть Windows.h в Microsoft Visual Studio
- 7 ответов
- Смотрите также:
- Cannot open Windows.h in Microsoft Visual Studio
- 7 Answers 7
- Include windows h ошибка
- Answered by:
- Question
- fatal error C1083: Cannot open include file: ‘Windows.h’: and scons
- 6 Answers 6
Не удается открыть Windows.h в Microsoft Visual Studio
Прежде всего: я использую Microsoft Visual Studio 2012
Я разработчик на C # / Java и сейчас пытаюсь программировать для kinect, используя Microsoft SDK и C ++. Итак, я начал с примера Основы цвета, и я не могу заставить его скомпилировать.
Сначала ни один из классов не смог найти Windows.h. Поэтому я установил (или переустановил, я не уверен) Windows SDK и добавил каталог включения SDK во включаемый «путь» проекта. Тогда все проблемы исчезли, кроме одной:
И это ошибка. Нет причин, по которым система может найти его, потому что он используется в нескольких других файлах, только этот файл не может с ним работать. В качестве ссылки, весь файл, который содержит ошибки (ColorBasics.rc):
Решение
Если вы этого еще не сделали, попробуйте добавить «SDK PathInclude» чтобы:
И добавить «SDK PathLib» чтобы:
Также попробуйте поменять «Windows.h» в
Если это не поможет, проверьте физическое существование файла, он должен находиться в папке « VC PlatformSDK Include» в каталоге установки Visual Studio.
Другие решения
Запустите Visual Studio. Перейдите в Инструменты-> Параметры и разверните Проекты и решения.
Выберите каталоги VC ++ из дерева и выберите «Включить файлы» в комбинированном списке справа.
Тебе следует увидеть:
Если этого не хватает, вы нашли проблему. Если нет, найдите файл. Он должен быть расположен в
C: Program Files Microsoft SDKs Windows v6.0A Включить
C: Program Files (x86) Microsoft SDKs Windows v6.0A Включить
если VS был установлен в каталог по умолчанию.
Если вы ориентируетесь на 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. Открой Отдельные компоненты вкладка и прокрутите вниз до Компиляторы, инструменты сборки и среды выполнения. Около дна, проверьте Поддержка Windows XP для C ++ и нажмите изменять начать установку.

Смотрите также:
Я получил эту ошибку фатальная ошибка lnk1104: не могу открыть файл ‘kernel32.lib’. эта ошибка возникает из-за отсутствия пути в каталогах VC ++. Для решения этой проблемы
Откройте Visual Studio 2008
В моем случае это C: Program Files Microsoft SDKs Windows v6.0A Lib
Источник
Не удается открыть Windows.h в Microsoft Visual Studio
Прежде всего: я использую Microsoft Visual Studio 2012
Я разработчик C # / Java и сейчас пытаюсь программировать для kinect с помощью Microsoft SDK и C ++. Итак, я начал с примера Color Basics, и я не могу его скомпилировать. Сначала ни один из классов не смог найти Windows.h. Итак, я установил (или переустановил, я не уверен) Windows SDK и добавил каталог include SDK в «путь» к проекту. Потом все проблемы исчезли, кроме одной:
И в этом ошибка. Нет причин, почему система может его найти, потому что он используется в нескольких других файлах, только этот файл не может работать с ним. Для справки весь файл с ошибками (ColorBasics.rc):
7 ответов
Если вы еще этого не сделали, попробуйте добавить «SDK PathInclude» в:
И добавьте «SDK PathLib» в:
Также попробуйте изменить «Windows.h» на
Если не поможет, проверьте физическое существование файла, он должен находиться в папке « VC PlatformSDK Include» в каталоге установки Visual Studio.
Я получил эту ошибку: фатальная ошибка lnk1104: не удается открыть файл kernel32.lib. эта ошибка возникает из-за того, что в каталогах VC ++ нет пути. Для решения этой проблемы
Откройте Visual Studio 2008
В моем случае это C: Program Files Microsoft SDK Windows v6.0A Lib
Необходимо выбрать правильную комбинацию версии Windows SDK и набора инструментов платформы. Конечно, это зависит от того, какой набор инструментов у вас установлен в данный момент.

1) Перейдите на C:Program Files (x86)Microsoft SDKsWindowsv7.1A for VS2013
3) Вставьте их в C:Program Files (x86)Microsoft Visual Studio 12.0VC
Я решил свои проблемы вроде:
ошибка lnk1104: не удается открыть файл kernel32.lib.
ошибка c1083: не удается открыть Windows.h
В моем случае мне пришлось щелкнуть решение правой кнопкой мыши и выбрать «Перенацелить проекты». В моем случае я перенацелил на Windows SDK версии 10.0.1777.0 и Platform Toolset v142. Мне также пришлось изменить «Windows.h» на
Я запускаю Visual Studio 2019 версии 16.25 на компьютере с Windows 10


Смотрите также:
Запустите Visual Studio. Перейдите в Инструменты-> Параметры и разверните Проекты и решения. Выберите в дереве каталоги VC ++ и выберите «Включить файлы» из выпадающего списка справа.
Тебе следует увидеть:
Если он отсутствует, вы обнаружили проблему. Если нет, найдите файл. Он должен находиться в
C: Program Files Microsoft SDK Windows v6.0A Include
C: Program Files (x86) Microsoft SDK Windows v6.0A Include
Если VS был установлен в каталог по умолчанию.
Источник
Cannot open Windows.h in Microsoft Visual Studio
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:
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):


7 Answers 7
If you already haven’t done it, try adding «SDK PathInclude» to:
And add «SDK PathLib» to:
Also, try to change «Windows.h» to
If won’t help, check the physical existence of the file, it should be in «VCPlatformSDKInclude» folder in your Visual Studio install directory.

Start Visual Studio. Go to Tools->Options and expand Projects and solutions. Select VC++ Directories from the tree and choose Include Files from the combo on the right.
If this is missing, you found a problem. If not, search for a file. It should be located in
C:Program FilesMicrosoft SDKsWindowsv6.0AInclude
C:Program Files (x86)Microsoft SDKsWindowsv6.0AInclude
if VS was installed in the default directory.

If you are targeting Windows XP ( v140_xp ), try installing Windows XP Support for C++.
Starting with Visual Studio 2012, the default toolset (v110) dropped support for Windows XP. As a result, a Windows.h error can occur if your project is targeting Windows XP with the default C++ packages.

Open the Visual Studio Installer and click Modify for your version of Visual Studio. Open the Individual Components tab and scroll down to Compilers, build tools, and runtimes. Near the bottom, check Windows XP support for C++ and click Modify to begin installing.
Источник
Include windows h ошибка
This forum has migrated to Microsoft Q&A. Visit Microsoft Q&A to post new questions.
![]()
Answered by:

Question


I have looked through the other posts concerning this error and I am sure that this situation is different.
I have a C++ COM ATL project and am trying to use CStringList which resides in
fatal error C1189: #error : WINDOWS.H already included. MFC apps must not #include
I’d be very grateful for any help. By the way the stdafx.h file looks like this:
#pragma once
#ifndef STRICT
#define STRICT
#endif
// Modify the following defines if you have to target a platform prior to the ones specified below.
// Refer to MSDN for the latest info on corresponding values for different platforms.
#ifndef WINVER // Allow use of features specific to Windows 95 and Windows NT 4 or later.
#define WINVER 0x0400 // Change this to the appropriate value to target Windows 98 and Windows 2000 or later.
#endif
#ifndef _WIN32_WINNT // Allow use of features specific to Windows NT 4 or later.
#define _WIN32_WINNT 0x0400 // Change this to the appropriate value to target Windows 2000 or later.
#endif
#ifndef _WIN32_WINDOWS // Allow use of features specific to Windows 98 or later.
#define _WIN32_WINDOWS 0x0410 // Change this to the appropriate value to target Windows Me or later.
#endif
#ifndef _WIN32_IE // Allow use of features specific to IE 4.0 or later.
#define _WIN32_IE 0x0400 // Change this to the appropriate value to target IE 5.0 or later.
#endif
#define _ATL_APARTMENT_THREADED
#define _ATL_NO_AUTOMATIC_NAMESPACE
#define _ATL_CSTRING_EXPLICIT_CONSTRUCTORS // some CString constructors will be explicit
// turns off ATL’s hiding of some common and often safely ignored warning messages
Источник
fatal error C1083: Cannot open include file: ‘Windows.h’: and scons
Today is officially my first day with C++ 😛
I’ve downloaded Visual C++ 2005 Express Edition and Microsoft Platform SDK for Windows Server 2003 SP1, because I want to get my hands on the open source Enso Project.
So, after installing scons I went to the console and tried to compile it using scons, but I got this error:
After checking these links:
I’ve managed to configure my installation like this:

And even run this script

And I managed to compile the file below in the IDE.
But I still get that exception in the console. Does anyone have scons experience?
EDIT
Actually (and I forgot to tell you this) I started the command prompt with the link «Visual Studio 2005 Command Prompt».
I assume this will include the paths in environment variables. Well after printing them I find that it didn’t:
Still, scons seeems not to take the vars. 🙁

6 Answers 6
You need to set the include file path (and possibly other things). At the command line this is typically done using a batch file that Visual Studio installs called vsvars32.bat (or vcvars32.bat for compatibility with VC6).
I’m not familiar with scons so I don’t know the best way to get these settings configured for that tool, but for standard makefiles there’s usually a line in the makefile which sets a macro variable with the include directory path and that macro is used as part of a command line parameter in the command that invokes the compiler.
Another possibility might be to have the scons process invoke vsvars32.bat or run the scons script from a command line that has been configured with the batch file.
In short you need to get the things that vsvars32.bat configures into the scons configuration somehow.
Источник