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

    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.

    Saturday, April 22, 2006 2:06 AM

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 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.
    Saturday, April 22, 2006 11:10 AM

All replies

  • 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.
    Saturday, April 22, 2006 11:10 AM
  • 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)

    Wednesday, April 26, 2006 1:26 AM
  • 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!

    Tuesday, September 19, 2006 7:25 PM
  • 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.
    Tuesday, September 19, 2006 8:24 PM
  • 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"

    Friday, March 02, 2007 11:00 PM
  • 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
    Wednesday, July 04, 2007 12:24 AM
  • The better choice for this is to edit the rc file and repace afxres.h with windows.h.
    • Proposed as answer by jd_inca Thursday, November 18, 2010 7:08 PM
    Wednesday, July 04, 2007 11:44 AM
  • 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.

    Wednesday, July 04, 2007 7:28 PM
  • 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.

    Wednesday, July 04, 2007 10:06 PM
  • 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)

     

    Thursday, July 05, 2007 5:28 PM
  • 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.

    Thursday, July 05, 2007 5:39 PM
  • 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.

    Thursday, July 05, 2007 7:25 PM
  • 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.

    • Proposed as answer by 神秘人 Wednesday, May 04, 2011 1:14 AM
    Thursday, July 05, 2007 7:29 PM
  • 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.

     

     

    Thursday, July 05, 2007 7:38 PM
  • Ok, thanks for your help, crescens2k.
    Thursday, July 05, 2007 7:39 PM
  • So, Why the Microsoft in it's examples for DirectX dinput joystick for MVC ++ use  afxres.h. And moust important question is how they manage to make it works

    Tuesday, November 20, 2007 8:39 PM
  • Simple and very effective. Many thanks!

    Thursday, August 28, 2008 8:23 PM
  •  

    Replacing #include "afxres.h" for #include "windows.h" did the trick for me.
    Friday, November 14, 2008 5:17 PM
  • Where exactly would one edit this #include "afxres.h" for #include "windows.h" at? I'm a novice user at best .

     

    Thursday, December 04, 2008 8:55 AM
  • I had the same problem.  But I was using Visual Studio 2008 Professional Edition, so the VC Express problem did not apply.  However, in my case the RC1015 error happened when the project was configured in Release config, but worked in Debug.  I checked the Include directories but kept missing to look at the option to include "standard include files". 

    The debug config has it checked, but release config did not.  This one drove me insane for a few days.  The problem happened because the version of Visual Studio I used had the standarad include files disabled by default.
    Friday, April 10, 2009 1:10 AM
  • Hi everyone,
    I solved this issue by editing the resource file and replacing "afxres.h" by "windows.h",
    as it was mentioned here, and it worked.

    Maybe it's because my code didn't need mfc libs to run, so it may be useful to others.

    Cheers.

    Sunday, December 20, 2009 3:06 PM
  • Thanks. replacing "afxres.h" with  "windows.h" did the trick.
    Wednesday, January 12, 2011 6:25 PM
  • The better choice for this is to edit the rc file and repace afxres.h with windows.h.

    This really helped me in Visual C++ 2008 Express Edition. Thank you!
    • Edited by artnib Friday, February 11, 2011 2:24 PM errata
    Friday, February 11, 2011 2:23 PM
  • The better choice for this is to edit the rc file and repace afxres.h with windows.h.


    This is only for VC-Express. I had the problem with standard Visual Studio, where this is not a good idea, because the .RC file will be auto-edited upon any resource-change and the afxres.h will return.

    "I'll be back - hasta la vista, hombre!" ;)

     

    Thursday, February 24, 2011 10:08 AM
  • I also had this problem (c++ visual studio 2008/64bit), the #include was in a resource file (.rc). Appearently a resource file doesn't look at your additional include directories.

    I had to set the full path, than everything worked:

    #include "C:\Program Files (x86)\dummy dir\dummyFile.h"   

    Thursday, May 19, 2011 9:12 AM