Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

MFC development in vs2017

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?

like image 551
Louis Avatar asked Mar 28 '17 15:03

Louis


People also ask

What is MFC software development?

MFC is a library that wraps portions of the Windows API in C++ classes, including functionality that enables them to use a default application framework. Classes are defined for many of the handle-managed Windows objects and also for predefined windows and common controls.

Is MFC still useful?

MFC is still used for some new development, and a lot of maintenance development (including inside of Microsoft). While it can be minutely slower than using the Win32 API directly, the performance loss really is tiny -- rarely as much as a whole percent.

How do I create an MFC project in Visual Studio?

To create an MFC forms or dialog-based applicationFrom the main menu, choose File > New > Project. Under the Installed templates, choose Visual C++ > MFC/ATL. If you don't see these, use the Visual Studio Installer to add them. Choose MFC Application from the center pane.

What is MFC and ATL?

The Microsoft Foundation Classes (MFC) provide a C++ object-oriented wrapper over Win32 for rapid development of native desktop applications. The Active Template Library (ATL) is a wrapper library that simplifies COM development and is used extensively for creating ActiveX controls.


2 Answers

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.

like image 196
Jerry Coffin Avatar answered Oct 08 '22 20:10

Jerry Coffin


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.

like image 32
Richard Chambers Avatar answered Oct 08 '22 21:10

Richard Chambers