I’m trying to compile an old project using VS express 2010 but I get this error:
fatal error RC1015: cannot open include file ‘afxres.h’. from this code
/////////////////////////////////////////////////////////////////////////////
//
// Generated from the TEXTINCLUDE 2 resource.
//
#include "afxres.h"
I have installed Windows SDK already, but without any success.
thanks!
asked Aug 25, 2010 at 12:57
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.h
with windows.h
in your terrain2.rc
.
answered Aug 25, 2010 at 13:03
4
Had the same problem . Fixed it by installing Microsoft Foundation Classes for C++.
- Start
- Change or remove program (type)
- Microsoft Visual Studio
- Modify
- Select ‘Microsoft Foundation Classes for C++’
- Update
In in the Visual Studio Installer for VS 2022 this may be listed as an individual component: «C++ MFC for latest v143 build Tools (x86 & x64)», but you may need to adapt this for your platform and latest version available.
answered Jul 23, 2013 at 10:47
Colonel PanicColonel Panic
132k85 gold badges399 silver badges462 bronze badges
1
Even I too faced similar issue,
fatal error RC1015: cannot open include file ‘afxres.h’. from this code
Replacing afxres.h with Winresrc.h and declaring IDC_STATIC as -1 worked for me.
(Using visual studio Premium 2012)
//#include "afxres.h"
#include "WinResrc.h"
#define IDC_STATIC -1
answered Jul 3, 2013 at 17:22
ravi.zombieravi.zombie
1,4721 gold badge20 silver badges23 bronze badges
1
Alternatively you can create your own 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
answered Sep 12, 2014 at 13:45
GerbenGerben
1611 silver badge2 bronze badges
0
You can also try replace afxres.h with WinResrc.h
answered Oct 1, 2012 at 12:20
IrbisIrbis
11.3k6 gold badges38 silver badges64 bronze badges
1
managed to fix this by copying the below folder from another Visual Studio setup (non-express)
from
C:Program Files (x86)Microsoft Visual Studio 12.0VCatlmfc
to
C:Program Files (x86)Microsoft Visual Studio 11.0VCatlmfc
answered Jan 10, 2015 at 14:05
Tiago DuarteTiago Duarte
3,2243 gold badges23 silver badges28 bronze badges
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.
Right click on the file *.rc, it will open:
And change as following:
answered Jun 6, 2015 at 19:55
ingcontiingconti
10.8k3 gold badges61 silver badges47 bronze badges
0
I faced same issue on VS 2019. My solution was to install C++ MFC library from Individual Components tab. When you open Visual Studio go to Tools->GetToolsAndFeatures->IndividualComponents
Select and install:
- MSVC v142 — VS 2019 C++ x64/x86 build tools (Latest)
- C++ ATL for latest v142 build tools (x86 & x64)
- C++ MFC for latest v142 build tools (x86 & x64)
answered Jun 22, 2022 at 23:38
Darko VDarko V
491 silver badge5 bronze badges
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
answered Oct 7, 2015 at 8:11
OlppahOlppah
7611 gold badge10 silver badges21 bronze badges
- Remove From My Forums
-
Question
-
Hi Folks:
Last night, while trying to get VS 2015 to use the Windows 10 SDK, I managed to mess up the IDE to the point where a fresh install sounded like a good idea.
I went to MS’s VS Community site for the latest download. 2017 is now the default offered version, so I downloaded and installed it.
The compilation failed. The only error found is in the .RC file:
///////////////////////////////////////////////////////////////////////////// // // Generated from the TEXTINCLUDE 2 resource. // #include "afxres.h"
Nothing was found when I searched for the header file on the C: drive.
Commenting out the include caused other errors.
Suggestions?
Thanks
Larry-
Edited by
Tuesday, March 14, 2017 11:50 PM
-
Edited by
Answers
-
Hi,
thanks for posting here.
>>VS 2017 .RC file — Error RC1015 cannot open include file ‘afxres.h’
For this case, I suggest you check if you have installed vc++ feature especially the MFC support with vs2017.
If not, please modify your vs2017 and add these features.
Hope this could be help of you.
Best Regards,
Sera Yu
MSDN Community Support
Please remember to click «Mark as Answer» the responses that resolved your issue, and to click «Unmark as Answer» if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to
MSDN Support, feel free to contact MSDNFSF@microsoft.com.-
Marked as answer by
a_unique_name
Wednesday, March 15, 2017 10:34 AM
-
Marked as answer by
##[error]OldWindowsAppOldWindowsApp.rc(10,0): Error RC1015: cannot open include file 'afxres.h'.
Upon further investigation, changing the platform version from v142 to v143 will fix the build issue. Older applications that don’t seem to be MFC library dependent still depend on artifacts like afxres.h and afxres.rc.
It does seem on the windows 2022 image that MSVC v142 is installed. Therefore my expectation would be that C++ MFC for v142 would also be installed (which I believe is the package in Visual Studio that would fix this issue).
- Remove From My Forums
-
Question
-
I am trying to compile samurize plugin for T-Balancer: http://www.samurize.com/modules/mydownloads/visit.php?cid=6&lid=1897 and whatever I do I receive message from the subject.
I followed «Using Visual C++ 2005 Express Edition with the Microsoft Platform SDK» and it did not help.
I have read somewhere that problem can be related to too long paths. Even so I have no idea how to make them shorter. Also information that ‘afxres.h‘ is related to MFC does not help.
I just want to compile some examples and every second attempt ends up with that very annoying message.
Answers
-
Solved and in case if anybody is interested:
After Microsoft Platform SDK is installed its /include folder consists subfolder /mfc. All necessary files seem to be there. Microsoft’s instruction: «Using Visual C++ 2005 Express Edition with the Microsoft Platform SDK» explains that following line: «C:Program FilesMicrosoft Platform SDKinclude» must be added to «the Visual C++ directories in the Projects and Solutions section in the Options dialog box». But does not say anything about line: «C:Program FilesMicrosoft Platform SDKincludemfc». Add it as well what, hopefully, will solve problems.
При компиляции проекта произошла следующая ошибка:
error RC1015: cannot open include file ‘afxres.h’.
Файл afxres.h относится к MFC. Есть два решения этой ошибки:
способ 1:
Проект-> Свойства-> Каталог VC ++-> Включить каталог, добавить D: VS VS2012 VC atlmfc include, как показано на рисунке, добавить путь как путь установки VS VC atlmfc include, добавить правильно, как показано на рисунке ниже Покажи, перекомпилируй проект и все получится.
Способ 2:
1. Войдите в режим обслуживания VS и установите MFC. Достаточно много времени. (Не рекомендуется)
2. Если ваш код вообще не использует MFC, просто добавьте
#Include «afxres.h» Изменить на
#include <Windows.h>
#include <winres.h>
Как показано ниже, перекомпилируйте проект, и он будет успешным.
Ссылка для справки:
https://stackoverflow.com/questions/3566018/cannot-open-include-file-afxres-h-in-vc2010-express