error RC1015: cannot open include file 'afxres.h'. 的解决办法

编译工程时出现如下错误:

error RC1015: cannot open include file 'afxres.h'.

 ‘afxres.h’ 文件是跟MFC相关的,出现此种错误有两种解决办法:

方法1:

项目->属性->VC++目录->包含目录,添加D:\VS\VS2012\VC\atlmfc\include,如图所示添加的路径为vs安装路径\VC\atlmfc\include,正确添加如下图所示,重新编译工程,即可成功。

error RC1015: cannot open include file 'afxres.h'. 的解决办法

方法2:

      1.进入VS的维护模式,把MFC给装上。蛮费时间的。(不推荐)

      2.如果你的代码根本就没用到MFC,那么,简单地把你资源文件中的

         #include "afxres.h"  改为

         #include <Windows.h>
         #include <winres.h>

        如图下所示,重新编译工程,即可成功。

error RC1015: cannot open include file 'afxres.h'. 的解决办法

参考链接:

https://*.com/questions/3566018/cannot-open-include-file-afxres-h-in-vc2010-express