none
Cannot build console application with Microsoft Visual Studio 2019 RRS feed

  • Question

  • I just installed the community version of VS 2019. I selected to build a console application that it created for me ("hello world" program). The file created is called ConsoleApplication1.cpp. I went to the build menu, selected build, and get the following error:

    1>------ Build started: Project: ConsoleApplication1, Configuration: Debug Win32 ------

    1>C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Microsoft\VC\v160\Microsoft.CppBuild.targets(441,5): warning MSB8003: The WindowsSDKDir property is not defined. Some build tools may not be found.

    1>ConsoleApplication1.cpp

    1>C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.24.28314\include\yvals.h(12,10): fatal error C1083: Cannot open include file: 'crtdbg.h': No such file or directory

    1>Done building project "ConsoleApplication1.vcxproj" -- FAILED.

    I tried to follow directions I saw on stackexchange. When I select "Project -> Properties" the Windows SDK field is blank. A value I typed in from another StackExchange message creates an error that that version of the SDK cannot be found. So I made the SDK field blank again. I also tried using "10.0", but that did nothing.

    Perhaps I did not install all the needed components. I recently checked off: "Windows Universal CRT SDK" (as per something I saw on stackexchange), but the build still fails. The warning is interesting. I looked that up also but have not found a solution that works. My "Platform Toolset" is Visual Studio 2019 (v142).

    What might still be missing to build a console application? Thank you. I am working on Windows 7.

    Saturday, December 7, 2019 10:31 AM

All replies

  • Did you install the "Desktop development with C++" workload as is documented at https://docs.microsoft.com/en-us/cpp/build/vscpp-step-0-installation?view=vs-2019#step-4---choose-workloads

    Saturday, December 7, 2019 11:49 AM
  • Did you actually install a version of the Windows 10 SDK with Visual Studio?

    This is REQUIRED to build console applications. It doesn't matter what version, but one version of the Windows 10 SDK is needed.

    If you have this installed in the Visual Studio installer, check the Windows 10 SDK directory itself.

    The file should exist. If it doesn't but the Visual Studio installer states that the Windows 10 SDK is installed then the setup was corrupt and you should do a repair install.

    Also, if you notice that the path of the include directory has the same version of the Windows 10 SDK. If you have a different SDK installed, then change the path appropriately.


    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.

    Saturday, December 7, 2019 12:59 PM
  • Hi amannuc,

    Welcome to MSDN forum.

    Thanks for replies of RLWA32 and Darran Rowe.

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

    ## According to your description, I suppose the error is caused by your missing Windows SDK. The Windows SDK is not installed by default. So if you need, I suggest you install it by the following method: open your installer -> click Modify -> select the Desktop development with C++ workload -> install it. Then, the Windows 10 SDK will be included.

    In addition, you could also install the Windows SDK by selecting individual components. The screenshot on my side is as follows:

    BTW, if my reply doesn’t work, I suppose the C1083 error is caused by other reasons. You could refer to the link.

    Hope all above will help you and any feedback will be greatly expected.

    Best Regards, 

    Anna 


    MSDN Community Support Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com

    Monday, December 9, 2019 3:49 AM
  • Hi amannuc,

    I noticed that you use windows 7 system. I'm not very sure if it is possible to install or download Win10 SDK. I am trying to create a windows 7 environment but there is something wrong with it temporarily.

    I will then try to test in my side and share you with my suggestions.

    Sorry for any inconvenience.

    Best Regards,

    Tianyu


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Tuesday, December 10, 2019 10:03 AM
  • Hi amannuc,

    Sorry for delay in reply.

    I have tested in my side by creating a windows 7 environment and download then install Visual Studio Community 2019 from official website.

    Before starting installing Visual Studio, I just select and install “Desktop development with C++” Workloads. And after finishing installing, I create a new C++ Console Application then build it. Everything seems to work well without any error.

    Do you use the latest version of Windows 7? According to Visual Studio 2019 System Requirements, I think you might need to confirm if your system meets this requirement: Windows 7 SP1 (with latest Windows Updates): Home Premium, Professional, Enterprise, Ultimate.

    In addition, please refer to this document: This version of Windows is not supported. If you’re running Windows 7,try installing Service Pack 1.

    Any feedback will be expected.

    Best Regards,

    Tianyu


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Wednesday, December 11, 2019 5:39 AM
  • Hi amannuc

    Sorry to disturb you.

    Did you have any update? Please let me know if the issue persists.

    If the issue is achieved, could you share your solution to others?

    If not, please feel free to contact us, we will try our best to help you.

    Have a nice day.

    Best Regards,

    Anna 


    MSDN Community Support Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com

    Friday, December 13, 2019 10:19 AM