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

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.



Answer this question

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

  • Shajan Dasan

    Yes, replace all instances of it with windows.h.

    As far as the #if, hmm, it looks like it is there for MFC resource DLLs so it probably won't hurt you, since it would hit that case normally. Although, if you want to be safe you can just remove it.



  • Marco Sousa

    crescens2k, I assume you mean to replace every instance of afxres.h with windows.h It doesn't just appear in one location for me:

    Code Snippet

    /////////////////////////////////////////////////////////////////////////////

    //

    // Generated from the TEXTINCLUDE 2 resource.

    //

    #include "afxres.h"

    .

    .

    .

    2 TEXTINCLUDE

    BEGIN

    "#include ""afxres.h""\r\n"

    "\0"

    END

    And there's also this line of code which seems to be related:

    Code Snippet

    #if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)



  • Thomas van der Heijden (old)

    I must be missing something painfully obvious. I have entered the Platform SDK path into the given screen, including the \mfc part, but still I get:

    c:\documents and settings\monty\my documents\visual studio 2005\projects\nettest2\nettest2\stdafx.h(45) : fatal error C1083: Cannot open include file: 'afxwin.h': No such file or directory

    All I need is a simple HTTP client that can send my file data to a PHP script. I'm running my software in XP and Server '03 environments, and don't mind using MFC and/or .NET 2.0, I just need to tell this ()*&)&*)(&* compiler that the include files are right there!



  • Gecko2648

    hi there.
    I struggled now a few times with this and what always helped perfect was copying the altmfc directory from my entire VS 2003 installation from my student times as is into the the VC dir in express and link it in the directory options. I have always done this under time pressure, so could well be I'm not actually using the lib code and so header files are enough for me, but not everybody...
    Cheers

  • Lauren Lavoie - MS

    I struggled with this for a whole day and all the internet postings are useless. I know this probably isn't the best solution, but it works.

    In solution explorer, under resource files, right click your .rc file and select properties. Under resource > general > additional include directories, add the following: ;"$(VCInstallDir)atlmfc\include";"$(VCInstallDir)PlatformSDK\Include"


  • itsonlyme4

    That will only give you the include files. If you actually call anything from MFC then you will not have MFC LIB files to link to because the Platform SDK only comes with 64 bit version of the libs.

    In fact, Visual C++ Express is not meant to be used with MFC (they don't ship MFC at all with it). To get around this, the MFC source code that comes with the Platform SDK must be rebuilt to generate library files compatible with Visual C++ 2005 Express (there is a way to do this but it is by no means trivial)


  • zelda

    crescens2k, afxres.h does not include the definitions for IDOK, IDCANCEL, etc, in either VC++ 2003 or VC++ 2005. They don't exist in windows.h, either. They exist in WinUser.h, for both versions.

    You are right, Microsoft assumes you'll continue using the same IDE for the length of the project. But, they do have a conversion process which should work, and it does... it's just the directories are not set up, that's all. Their Platform SDK webpage is supposed to tell you how to rectify this, and for the most part, it does successfully, but it just forgets one directory -- the MFC one with afxres.h in it.



  • PaddyK

    It doesn't "wrongly" include afxres.h, under the VS IDE this is something useful. The afxres.h has some additional definitions for common control types, like IDOK, IDCANCEL and more. There are two more things to remember too, first of all, Microsoft has seemed to assume that when you create a project you will keep editing it on the same machine or the same IDE type, secondly there is no inbuild native resource handling for EE, meaning you manually edit it yourself.

    In the situation where these resource files were initally created there is no problems including afxres.h, but when you move them that is when problems could start occuring.



  • Mister T7718

    I had the same problem with trying to compile a resource file from VC++7.1. Adding "C:\Program Files\Microsoft Platform SDK\include\mfc" to the VC++ directories include files fixed the issue. I wasn't even using MFC, but for some reason it needs the afxres.h file (I think because it includes windows.h), even though it doesn't need any MFC stuff.

    This "fix" should be mentioned in this document, along with the rest of the required changes to VC++ directories.

    http://msdn.microsoft.com/vstudio/express/visualc/usingpsdk/

    Of course, if the resource files from VC++7.1 didn't wrongly include an MFC file, and simply included windows.h, as it should, this wouldn't be a problem.



  • Felice

    The better choice for this is to edit the rc file and repace afxres.h with windows.h.

  • satyam

    Ok, so the VC++7.1 IDE needs afxres.h for some defines for its resource editor. And VC++8.0 Express, since it has no resource editor, doesn't need it. That's why removing the reference to afxres.h, and replacing it with windows.h, is fine in VC++8.0 Express, where it presumably wouldn't be in VC++7.1, since windows.h doesn't have the definitons that afxres.h has that its resource editor needs I hope I got that right.



  • Commali

    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 Files\Microsoft Platform SDK\include" 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 Files\Microsoft Platform SDK\include\mfc". Add it as well what, hopefully, will solve problems.

  • Englestone

    Misfire there, you are right, about it not defining those, it defines menu, toolbar and other things to make using the resource editor in the VS IDE easier.

    But the Platform SDK webpage has nothing wrong. The version of the MFC in the Platform SDK is for 64 bit windows only. It was only intended as a supplement for VS.net and VS.net 2003. If you look it only has 64 bit compilers too.

    If you look in the latest version of the PSDK you will actually notice that there is no MFC or ATL libraries there at all. This shows that since they are now in VS properly there is no need to distribute them with the PSDK.

    There is only two ways are supposed to get the MFC, through VS or the WDK.

    In all, the Express edition was not designed to work with MFC or ATL. It doesn't have the resource editor, which relies on MFC to work. Yes, if you get hold of the MFC then you can hook it up to VC but it is not intended for that.



  • xishan shigri

    The version of MFC that ships with the PSDK is a 64-bit version (it dates from the days when the PSDK was the only way to get 64-bit tools). Even if you manage to include the header files and link you'll probably discover that the code won't execute.

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