CnC_Remastered_Collection
CnC_Remastered_Collection copied to clipboard
Cannot open include file "afxres.h"
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.
I don't explicitly remember seeing that when I built with VS 2019.
Here is what I did:
- Loaded .sln into VS
- Retargeted to Windows 10 and C++ v142 build tools
- Downloaded v142 build tools (C++ MFC) via Visual Studio Installer
- 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.
- Build
Here is my fork if you want to see the config and whatnot: https://github.com/alexlk42/CnC_Remastered_Collection
Replace with #include <windows.h>
... 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.
Can confirm @alexlk42 approach works. I had the same problem (missing afxres.h), but step 3) fixed it for me.
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 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.
@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.
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.