electronicarts / CnC_Remastered_Collection

Other
18.31k stars 4.74k forks source link

Cannot open include file "afxres.h" #36

Open N-Hoque opened 4 years ago

N-Hoque commented 4 years ago

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.

alexlk42 commented 4 years ago

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

cornmonger commented 4 years ago

Replace with #include

kbrantley commented 4 years ago

... 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.

jth commented 4 years ago

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

wolfebrian2120 commented 4 years ago

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.

RudolfKurka commented 4 years ago

@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.

wolfebrian2120 commented 4 years ago

@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.

markyoung2u commented 1 year ago

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