16

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!

Curly
  • 539
  • 2
  • 7
  • 14
  • Those files are installed with Visual Studio. Either you goofed up your include directories settings or they are not installed. – Captain Obvlious Apr 27 '15 at 14:27
  • Oh, good to know. Question here, could you let me know supposedly where the directory is for a normal vs 2015 ultimate setup? – Curly Apr 27 '15 at 14:49
  • 2
    I found "afxwin.h" under my directory of: C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\atlmfc\include\ How should I include this directory in my code? Thanks! – Curly Apr 27 '15 at 15:15
  • 2
    I think all you need to do is to select a proper platform toolset in the VC project property. Should be something like "v140" – cha Apr 28 '15 at 04:56
  • I figured it out by myself here. Right click External Dependencies at solution explorer, click "class wizard". Everything under \include would be automatically installed. – Curly Apr 28 '15 at 13:37
  • In my case (MSVC2022), I still get an error for downloading MFC library packages using VS Installer. Finally the only solution that worked has been to copy atlmfc directory from another PC and paste it into my PC. – LM.Croisez Jun 20 '22 at 13:18

3 Answers3

22

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.
thor
  • 21,418
  • 31
  • 87
  • 173
tf245yay
  • 323
  • 2
  • 5
  • I do not see this option in Visual Studio 2005 (using old version to target legacy Windows CE 6.0 application). Any suggestions for how to install this component in this case? – jacobq Oct 25 '16 at 18:37
  • For my scenario, I needed to do this with VS2015 installer even though I am opening project in VS2017/VS2019. – Malachi Jan 28 '20 at 19:15
  • 8
    For VS2019 Open the Installer, select `Modify` for your installation and select `C++ ATL for latest xxx build tools (xxx)` and `C++ MFC for latest xxx build tools (xxx)` in Individual components. Replace `xxx` accordingly to your version and platform. – dab0bby Feb 05 '20 at 13:02
  • I have the same error in a project, MFC is installed correctly because another MFC project works just fine. I have compared the settings in both projects with no luck :( – Juan Rojas Feb 13 '20 at 20:32
8

For VS2019 the above solutions didn't worked for me. I had to go to "Installer -> Individual Components -> " and install the following to solve the issue:

  • "MSVC v141 – VS 2017 C++ x64/x86 build tools (v14.16)"
  • "C++ MFC for v141 build tools (x86 & x64)"
  • "C++ ATL for v141 build tools (x86 & x64)"
igoyetche
  • 119
  • 1
  • 5
  • 2
    Make that "Tools -> Get Tools and Features [which opens the VS Installer and selects the VS instance you are currently using] -> Individual Components [the top tab, not the "Individual components" in the right pane]. Check the needed components and click 'Modify". The version ('v141') must match the target framework for the project (Solution Explorer [right-click Project] -> Properties -> Configuration Properties -> General -> Platform Toolset). The three components you identified are found in sections named "Compilers, build tools, and runtimes" and "SDKs, libraries, and frameworks". – Jimbo1987 Feb 03 '22 at 16:56
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)

u8it
  • 3,956
  • 1
  • 20
  • 33
  • 5
    In 2017 Visual Studio Installer it is under Modify / Individual Components / SDKs... / MFC and ATL support (x86 and x64) – Vladimir Shutow Mar 13 '18 at 19:34
  • This has helped me a lot. I spent almost half day searching which version should I install or what components. (y) Thank You @VladimirShutow – Chintan Jun 12 '18 at 18:00