C++ 无法在 VC2010 Express 中打开包含文件“afxres.h”

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/3566018/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-28 13:08:59  来源:igfitidea点击:

Cannot open include file 'afxres.h' in VC2010 Express

c++visual-studiowinapivisual-c++

提问by clamp

I'm trying to compile an old project using VS express 2010 but I get this error:

我正在尝试使用 VS express 2010 编译一个旧项目,但出现此错误:

fatal error RC1015: cannot open include file 'afxres.h'. from this code

致命错误 RC1015:无法打开包含文件“afxres.h”。从这个代码

/////////////////////////////////////////////////////////////////////////////
//
// Generated from the TEXTINCLUDE 2 resource.
//
#include "afxres.h"

I have installed Windows SDK already, but without any success.

我已经安装了 Windows SDK,但没有任何成功。

thanks!

谢谢!

回答by Kirill V. Lyadvinsky

This header is a part of the MFC Library. VS Express edition doesn't contain MFC. If your project doesn't use MFC you can safely replace afxres.hwith windows.hin your terrain2.rc.

此标头是 MFC 库的一部分。VS Express 版不包含 MFC。如果您的项目不使用MFC,你可以放心地更换afxres.hwindows.h你的terrain2.rc

回答by Colonel Panic

Had the same problem . Fixed it by installing Microsoft Foundation Classes for C++.

有同样的问题。通过安装用于 C++ 的 Microsoft 基础类来修复它。

  1. Start
  2. Change or remove program (type)
  3. Microsoft Visual Studio
  4. Modify
  5. Select 'Microsoft Foundation Classes for C++'
  6. Update
  1. 开始
  2. 更改或删除程序(类型)
  3. 微软视觉工作室
  4. 调整
  5. 选择“用于 C++ 的 Microsoft 基础类”
  6. 更新

enter image description here

在此处输入图片说明

回答by ravi.zombie

Even I too faced similar issue,

连我也面临类似的问题,

fatal error RC1015: cannot open include file 'afxres.h'. from this code

致命错误 RC1015:无法打开包含文件“afxres.h”。从这个代码

Replacing afxres.h with Winresrc.h and declaring IDC_STATIC as -1 worked for me. (Using visual studio Premium 2012)

用 Winresrc.h 替换 afxres.h 并将 IDC_STATIC 声明为 -1 对我有用。(使用 Visual Studio Premium 2012)

//#include "afxres.h"
#include "WinResrc.h"
#define IDC_STATIC  -1

回答by Gerben

Alternatively you can create your own afxres.h:

或者,您可以创建自己的 afxres.h:

#ifndef _AFXRES_H
#define _AFXRES_H
#if __GNUC__ >= 3
#pragma GCC system_header
#endif

#ifdef __cplusplus
extern "C" {
#endif

#ifndef _WINDOWS_H
#include <windows.h>
#endif

/* IDC_STATIC is documented in winuser.h, but not defined. */
#ifndef IDC_STATIC
#define IDC_STATIC (-1)
#endif

#ifdef __cplusplus
}
#endif
#endif   

回答by Irbis

You can also try replace afxres.h with WinResrc.h

您也可以尝试用 WinResrc.h 替换 afxres.h

回答by Tiago Duarte

managed to fix this by copying the below folder from another Visual Studio setup (non-express)

设法通过从另一个 Visual Studio 设置(非快速)复制以下文件夹来解决此问题

from C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\atlmfc

来自 C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\atlmfc

to C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\atlmfc

到 C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\atlmfc

回答by ingconti

a similar issue is for Visual studio 2015 RC. Sometimes it loses the ability to open RC: you double click but editor do not one menus and dialogs.

Visual Studio 2015 RC 也存在类似问题。有时它会失去打开 RC 的能力:你双击但编辑器没有一个菜单和对话框。

Right click on the file *.rc, it will open:

右键单击文件 *.rc,它将打开:

enter image description here

在此处输入图片说明

And change as following:

并更改如下:

enter image description here

在此处输入图片说明

回答by Olppah

Had similar issue but the message was shown when I tried to open a project solution. What worked for me was:

有类似的问题,但当我尝试打开项目解决方案时显示了该消息。对我有用的是:

TOOLS -> Import and Export Settings...-> Reset all settings

工具 -> 导入和导出设置...-> 重置所有设置