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

  • Question

  • I just got a new computer
    I installed Visual Studio 2017 Community Edition
    I copied my project files onto my new computer
    I get this error
    fatal error C1083: Cannot open include file: 'afxwin.h": No such file or directory

    This file afxwin.h is found in
    C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.16.27023\atlmfc\include

    My projects VC++ Directories has Include set to:
    $(VCInstallDir)include;$(VCInstallDir)atlmfc\include;$(WindowsSdkDir)include;$(FrameworkSDKDir)\include;D:\amb\wDirReport\LimeLM\TurboActivate_4_1_9_0\API\C

    I updated my VS2017 installation to include ALL MFC choices

    Visual C++ ATL (x86/x64) with Spectre Mitigations

    Visual C++ ATL for ARM

    Visual C++ ATL for ARM with Spectre Mitigations

    Visual C++ ATL for ARM64

    Visual C++ ATL for ARM64 with Spectre Mitigations

    Visual C++ ATL for x86 and x64

    Visual C++ MFC for ARM

    Visual C++ MFC for ARM with Spectre Mitigations

    Visual C++ MFC for ARM64

    Visual C++ MFC for x86 and x64

    Visual C++ MFC for x86/x64 with Spectre Mitigations

    Visual C++ MFC support for ARM64 with Spectre Mitigations


    Please help me


    • Edited by AllanIsKing Sunday, August 25, 2019 6:59 PM
    Sunday, August 25, 2019 6:58 PM

All replies

  • If you create a new MFC project, does it compile?

    This is a signature. Any samples given are not meant to have error checking or show best practices. They are meant to just illustrate a point. I may also give inefficient code or introduce some problems to discourage copy/paste coding. This is because the major point of my posts is to aid in the learning process.

    Sunday, August 25, 2019 7:43 PM
  • Hi,

    Thank you for posting here.

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

    I suggest you could try to click on "Tools" -> "Visual Studio Command Prompt", and then enter "set" to see all the environment variables.As shown below:

    VCINSTALLDIR=c:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\
    VCToolsInstallDir=c:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.16.27023\

    As far as I'm concerned you could try changing "VCInstallDir" to "VCToolsInstallDir".

    Best Regards,

    Jeanine Zhang

    Monday, August 26, 2019 2:08 AM
    Moderator
  • I apologise for the delay in this follow up, these forums have been acting up.

    After double checking the paths, it looks like you didn't properly set the include path to inherit from the Visual C++ and Windows include paths. While this worked in versions up to 2015, because the compiler paths changed in Visual Studio 2017, then the paths that you explicitly set no longer work for 2017 and newer.

    Your best option is to use the $(IncludePath) macro.

    This will inherit the include paths from the build system so it knows the proper location of the C++ and ATL/MFC headers, but you can also add on your own paths too.


    This is a signature. Any samples given are not meant to have error checking or show best practices. They are meant to just illustrate a point. I may also give inefficient code or introduce some problems to discourage copy/paste coding. This is because the major point of my posts is to aid in the learning process.

    Monday, August 26, 2019 2:54 AM
  • I suggest you could try to click on "Tools" -> "Visual Studio Command Prompt", and then enter "set" to see all the environment variables.As shown below

    I don't have this menu item - how do I add it?

    Tuesday, August 27, 2019 1:10 AM
  • Hi,

    You could also try to open "Visual Studio Command Prompt" from the Start menu.As shown below:

    >>I don't have this menu item - how do I add it?

    You could click on "Tools" -> "External tools" ,and then configure the Visual Studio Command Prompt tool. Click on "Add" to set the title, commands and parameters.

    Title: Visual Studio &Command Prompt
    Command: %systemroot%\system32\cmd.exe
    Arguments: /K "vsdevcmd.bat -no_logo"
    Initial Directory:This is the default initial directory after the command line is started, for example:
    "Target Directory", "Project Directory", "Solution Directroy". Of course, you could also customize an initial directory.

    As Darran said, your best option is to use the $(IncludePath) macro.

    Best Regards,

    Jeanine Zhang

    Tuesday, August 27, 2019 2:14 AM
    Moderator
  • Just a note

    I have Visual Studio 2017 Community on my old computer and it builds fine

    Thursday, August 29, 2019 8:53 PM
  • I gave up on getting the old project settings working

    So I created a new dummy project based on MFC
    and it buildt

    I copied over the VC directories
    and retarget projects to the latest version

    Thursday, August 29, 2019 10:23 PM
  • It is building and running now
    Thursday, August 29, 2019 10:23 PM
  • Hi,

    I am glad you have got your solution.Have you got any updates? If your case has been solved, please help to mark answers. If not, just feel free to contact us.

    Your understanding and cooperation will be grateful.

    Best Regards,

    Jeanine Zhang


    Friday, August 30, 2019 1:43 AM
    Moderator