30

When I installed vs2017, I did select Windows development with C++ option. After installation, however, I don't see the MFC has been added. Sure enough, I get errors when I compile my application,

fatal error C1083: Cannot open include file: 'afxwin.h': No such file or directory

I cannot find the Change/Modify option with my vs2017 installation in Control Panel. How can I add "Microsoft Foundation Classes for C++" package?

Daniel A. White
  • 187,200
  • 47
  • 362
  • 445
Louis
  • 660
  • 1
  • 7
  • 14
  • 1
    This Visual Studio developer community posting has an answer with screen shots of the procedure. https://developercommunity.visualstudio.com/content/problem/10857/cant-find-the-template-for-mfc-programming-in-file.html – Richard Chambers Sep 17 '17 at 05:44
  • See also this two part blog posting. [A Comprehensive comparison of the MFC & ATL changes in VS 2017 RC compared to Visual Studio 2015 Update 3 (Part 1)](https://naughter.wordpress.com/2017/01/02/a-comprehensive-comparison-of-the-mfc-atl-changes-in-vs-2017-rc-compared-to-visual-studio-2015-update-3-part-1/) and [A Comprehensive comparison of the MFC & ATL changes in VS 2017 RC compared to Visual Studio 2015 Update 3 (Part Two)](https://naughter.wordpress.com/2017/01/10/a-comprehensive-comparison-of-the-mfc-atl-changes-in-vs-2017-rc-compared-to-visual-studio-2015-update-3-part-two/) – Richard Chambers Sep 17 '17 at 05:48
  • Related: [C++ #include is not found](https://stackoverflow.com/q/3898287/3357935) – Stevoisiak Mar 11 '19 at 15:42

4 Answers4

40

If you look near the top of the VS Installer window, you'll see Workloads, Individual Components and Language Packs.

At least as far as I can see, none of the "Workloads" will include MFC in your installation. To get it, you first have to click on "Individual Components", then scroll quite a ways down to get to the "SDKs, libraries and frameworks" section. In there, you'll find a list of components for ATL and MFC support:

enter image description here

In the VS 2019 installer, the list of possibilities has gotten even longer. There are versions for ARM, ARM64, and x86/x64 both with and without Spectre mitigations, for each of the 141 and 142 build sets:

enter image description here

That's not necessarily the end of the story though: by default, even when you install that, it only installs the version Unicode build of MFC. If you want the narrow-character version, you have to install that separately. I don't think there's any entry in the installer to do this at all--but if you try to build a project that uses narrow-character MFC, you'll get an error message that includes a link to download it.

Jerry Coffin
  • 476,176
  • 80
  • 629
  • 1,111
  • 2
    I just tried it in the most recent version of VS2017 and it is not enabled by default, so @JerryCoffing is right, you have to manually enable it, either from the workloads pane or from the "Individual Components" pane (they both select the same packages). – Xan-Kun Clark-Davis Jun 05 '17 at 15:05
  • It looks like 'MFC and ATL support' [was removed in VS installer v.1.16.1247.518](https://developercommunity.visualstudio.com/comments/277844/view.html). – Stevoisiak Mar 11 '19 at 14:51
  • @StevenM.Vascellaro: I've edited the answer to show what to do with the current installer. – Jerry Coffin Mar 11 '19 at 15:13
  • @JerryCoffin How did 'MFC and ATL support' get split into 30 different components? – Stevoisiak Mar 11 '19 at 15:30
  • @StevenM.Vascellaro: As noted in the answer, "There are versions for ARM, ARM64, and x86/x64 both with and without Spectre mitigations, for each of the 141 and 142 build sets." IOW, combinatorial explosion. – Jerry Coffin Mar 11 '19 at 16:01
21

In Windows 10 with Visual Studio 2017 Community Edition to modify the Visual Studio 2017 installation, I had to go into Settings from the Windows Start menu then in the search box enter "Apps & Features" to bring up the list of installed applications (just typing in "apps" was enough to bring it up in the list).

I then looked for Microsoft Visual Studio 2017 in the list of apps, clicked on that entry which then displayed the Modify button. Clicking on the Modify button will bring up the installer to allow you to modify the various components.

I have seen cases where the installer wants to do an Update of Visual Studio 2017 before allowing you to do the Modify action. Depends on the last time you used it and the last time you did an update.

So instead of a Modify button there may instead be an Update button.

Note: see also How to install (v142) Build tools in Visual studio which describes issues seen with install order when installing both VS 2017 and VS 2019.

image of first dialog for Modify Visual Studio 2017 install

The VS 2017 Modify dialog has three tabs, "Workloads", "Individual components", and "Language packs". Click on the "Individual components" then scroll down to the section titled "SDKs, libraries, and frameworks" which is the last section in my install. There should be an entry for "MFC and ATL support (x86 and x64)" with a checkbox near the end.

image of Modify dialog showing the tabs

image of Modify dialog with Individual components tab showing MFC checkbox

There is a lot of stuff available from this "Individual components" view of the "Modify installation" dialog.

Richard Chambers
  • 16,643
  • 4
  • 81
  • 106
4

Just to add a tip for VS 2019:

@Jerry Coffin's answer does a good job of laying out the explosion of MFC/ATL options in VS 2019. Since there are many options and each MFC pack is 1.1+GB, here is how to pick the right one.

Platform: Hopefully you know this :) but it is in project properties.

Version: For an existing project, it is found in the project properties under "Configuration Properties -> General -> Platform Toolset"

Below is a screenshot showing both (Win32=x86 in this case). In this case I needed "C++ MFC for v141 build tools (x86 & x64)": Screenshot of project properties

MG83
  • 73
  • 1
  • 9
  • This was really useful. I didn't realise the project I was trying to compile used toolset v141 and I was using WFC 142 which caused an issue with the include – Leojet Feb 23 '23 at 18:39
1

You should use Visual Studio Installer to make changes.

To create an MFC project, you just need to select Win32 project/Win32 Console Application for your application type, and then click OK. In Application Wizard, click next, in Application Settings, check MFC under Add common header files for:.

Alex
  • 44
  • 5