CnC_Remastered_Collection icon indicating copy to clipboard operation
CnC_Remastered_Collection copied to clipboard

Cannot open include file "afxres.h"

Open N-Hoque opened this issue 4 years ago • 8 comments

I'm using Visual Studio 2019, running on Windows 10 and I'm using the Windows 10 SDK toolkit rather than the Windows 8.1 toolkit that the solution file uses by default. Trying to build the DLLs results in the error appearing.

N-Hoque avatar Jun 06 '20 16:06 N-Hoque

I don't explicitly remember seeing that when I built with VS 2019.

Here is what I did:

  1. Loaded .sln into VS
  2. Retargeted to Windows 10 and C++ v142 build tools
  3. Downloaded v142 build tools (C++ MFC) via Visual Studio Installer
  4. Defined WINDOWS_IGNORE_PACKING_MISMATCH a. Open RedAlert Property Pages -> C/C++ -> Preprocessor -> Add to Preprocessor Definitions b. Use semicolon to separate definitions c. Double check that it gets added to TiberianDawn Property Pages too.
  5. Build

Here is my fork if you want to see the config and whatnot: https://github.com/alexlk42/CnC_Remastered_Collection

alexlk42 avatar Jun 06 '20 18:06 alexlk42

Replace with #include <windows.h>

cornmonger avatar Jun 06 '20 19:06 cornmonger

... or, instead of modifying the source, you could pay attention to step 3 that was mentioned in @alexlk42's reply:

Downloaded v142 build tools (C++ MFC) via Visual Studio Installer

The specific component that needs to be installed is "C++ MFC for latest v142 build tools (x86 & x64)." Once that's installed, the preprocessor will be able to find afxres.h.

kbrantley avatar Jun 06 '20 21:06 kbrantley

Can confirm @alexlk42 approach works. I had the same problem (missing afxres.h), but step 3) fixed it for me.

jth avatar Jun 06 '20 22:06 jth

Hi I'm not sure the described solution works. I made sure I did step 4. but I am still recieving the afxres.h error. I even pulled @alexlk42 project and tried to build it. Perhaps I don't have the right build tool set. But I was pretty sure I selected it upon opening it.

wolfebrian2120 avatar Jun 07 '20 22:06 wolfebrian2120

@wolfebrian2120 I don't think that automatic installer that you get when opening a solution is enough. Run visual studio installer, select "Modify"->"Individual components" and tick "C++ MFC for latest v142 build tools (x86 & x64)" and you might also need c++ build tools for example "MSVC v142 - VS 2019 C++ x64/x86 build tools (v14.26)", it will probably select ATL components as well, leave that be and install.

RudolfKurka avatar Jun 08 '20 08:06 RudolfKurka

@Capt-Nemo- @alexlk42 I have confirmed that this works. I was able to get a successful build. with no errors. I needed to install the C++ 142 stuff following @Capt-Nemo- instructions.

wolfebrian2120 avatar Jun 19 '20 05:06 wolfebrian2120

I also had a missing afxres.h going to VS 2022 for ARM64 with toolset v1.43 but left x64 at 2019 toolset v1.42. This was not a problem on my old laptop which has both VS 2019 and VS 2022 installed, but my new laptop was VS 2022 only. I chose to install all 6 MFC for v1.42. Fixed the problem. image

markyoung2u avatar May 27 '23 23:05 markyoung2u