I converted my VS 2012 projects to VS 2015 by using the automatic conversion tool. When I try to load a resource file (.rc) it fails with this error:
fatal error RC1015: cannot open include file afxres.h
Any idea?
I have seen the same problem with console applications without MFC
that where generated with Visual Studio 2010
.
One solution is to modify the installation of Visual Studio 2015
to include MFC
. MFC
is not installed by default because of it's size. But in my opinion this should only be applied if you have applications that use MFC
.
If you only need MFC
for afxres.h
you can replace
#include "afxres.h"
[...]
"#include ""afxres.h""\r\n"
with
#include "WinResrc.h"
[...]
"#include ""WinResrc.h""\r\n"
You might need to add (but you will see that when compiling the resources).
#define IDC_STATIC -1
[...]
"#define IDC_STATIC -1""\r\n"
As you can see in the rc file one of the sections is TEXTINCLUDE
. When Visual Studio
's resource editor opens the rc file and saves it back to disc it takes this section and puts the text into the section marked with "Generated from the TEXTINCLUDE [...]". So take care to change both places of at least the TEXTINCLUDE
section so that resource editor can do the rest.
This answer on Thomson Reuters website worked for me. Adding for other users:
You probably need to modify the Visual Studio 2015 setup and add the MFC .
Please close VS2015 and go to Control Panel -> Programs and Features -> Microsoft Visual Studio -> Change -> Modify -> Add Microsoft Foundation Classes
See the figure below:
I'm using VS 2017 and I didn't need to install MFC. You can change the header to #include "winres.h"
instead. There are other minor changes with the #if
defines, so I strongly suggest you create a new .rc
resource file and do an A/B compare to see the differences (it is not much). I just compared the old with the new and migrated the differences.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With