cannot open source file “afxwin.h”/“afxext.h”/“afx

2019-04-20 05:09发布

问题:

I try to ran a previous written MFC c++ code on my visual studio 2015 MFC with multitype MFC library installed.

However, I still have 12 errors here regarding missing function:

IntelliSense: cannot open source file "afxwin.h" C1083 Cannot open include file: 'afxwin.h': No such file or directory cannot open source file "afxext.h"/"afxdisp.h"/"afxdtctl.h"/"afxcmn.h"/afxdisp.h etc....

Where can I get these head files?

Again, my set up is:

VIsual studio 2015 ultimate MFC Multibyte MFC library installed Windows 8 - 64 bit machine

Thanks!

回答1:

I just fixed a similar problem. Here's how you can resolve this.

  1. Go to your control panel
  2. Navigate to uninstall/change a program.
  3. Scroll down until you see your visual studio installation
  4. Click change
  5. Once the window pops up, click "Modify"
  6. Under Programming Languages -> Visual C++ Make sure "Microsoft Foundation Classes for C++" is checked. If it isn't select it and click update.


回答2:

For what it's worth. I was getting similar errors after a fresh installation of VS2017. I installed the C++ features from the main installer and created a new project with MFC checked. I assumed "Microsoft Foundation Classes for C++" was installed by this point, but I kept getting these errors. Furthermore, after saving and closing the solution for the first time, VS wouldn't load the project if I opened the solution from the recently used list because dependencies were missing.

What worked for me

I opened the solution file directly using VS2017. Finally, VS informed me that "Microsoft Foundation Classes for C++" was not installed and gave me the option to install it. I had previously looked through the installer features and could not find this option.

EDIT

Per Vladimir's comment below...

In 2017 Visual Studio Installer it ["Microsoft Foundation Classes for C++"] is under Modify / Individual Components / SDKs... / MFC and ATL support (x86 and x64)