Cannot build console application with Microsoft Visual Studio 2019 - c++

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 listed elsewhere on stackexchange. When I select "Project -> Properties" the Windows SDK field is blank. A value I typed in from the other StackExchange message creates an error that that version of the SDK cannot be found. So I deleted the version of the SDK and made it blank again. I also tried using "10.0" Here is where I received the advice:
Visual Studio 2017 errors on standard headers
Perhaps I did not install all the needed components. I recently checked off: "Windows Universal CRT SDK" (as per the instructions), 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.

Related

CMake can't get the value of VCTargetsPath when generating for UWP

I'm trying to use CMake to build a Universal Windows App, but I get the following build error (latest Visual Studio 2019 and Windows 10 SDK are installed):
› cmake -B. -H<my source dir> -DCMAKE_SYSTEM_NAME=WindowsStore -DCMAKE_SYSTEM_VERSION=10.0
-- Building for: Visual Studio 16 2019
-- Selecting Windows SDK version 10.0.19041.0 to target Windows 10.0.
CMake Error at CMakeLists.txt:3 (project):
Failed to run MSBuild command:
C:/Program Files (x86)/Microsoft Visual Studio/2019/Community/MSBuild/Current/Bin/MSBuild.exe
to get the value of VCTargetsPath:
Microsoft (R) Build Engine version 16.5.1+4616136f8 for .NET Framework
Copyright (C) Microsoft Corporation. All rights reserved.
Build started 5/16/2020 9:52:00 PM.
Project "C:\test\CMakeFiles\3.17.2\VCTargetsPath.vcxproj" on node 1 (default targets).
C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Current\Bin\Microsoft.Common.CurrentVersion.targets(777,5): error : The OutputPath property is not set for project 'VCTargetsPath.vcxproj'. Please check to make sure that you have specified a valid combination of Configuration and Platform for this project. Configuration='Debug' Platform='x64'. You may be seeing this message because you are trying to build a project without a solution file, and have specified a non-default Configuration or Platform that doesn't exist for this project. [C:\test\CMakeFiles\3.17.2\VCTargetsPath.vcxproj]
Done Building Project "C:\test\CMakeFiles\3.17.2\VCTargetsPath.vcxproj" (default targets) -- FAILED.
Build FAILED.
"C:\test\CMakeFiles\3.17.2\VCTargetsPath.vcxproj" (default target) (1) ->
(_CheckForInvalidConfigurationAndPlatform target) ->
C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Current\Bin\Microsoft.Common.CurrentVersion.targets(777,5): error : The OutputPath property is not set for project 'VCTargetsPath.vcxproj'. Please check to make sure that you have specified a valid combination of Configuration and Platform for this project. Configuration='Debug' Platform='x64'. You may be seeing this message because you are trying to build a project without a solution file, and have specified a non-default Configuration or Platform that doesn't exist for this project. [C:\test\CMakeFiles\3.17.2\VCTargetsPath.vcxproj]
0 Warning(s)
1 Error(s)
Time Elapsed 00:00:00.07
Exit code: 1
-- Configuring incomplete, errors occurred!
What does that mean? I've also tried to specify the exact Windows SDK version for CMAKE_SYSTEM_VERSION, but no luck.
I solved the problem. I did many things, therefore I cannot tell which one exactly solved the problem. But try the following.
From VisualStudio Installer app, click Modify and install C++ Universal Windows Platform support for v142 build tools (ARM64) individual component.

Unreal Engine 4.10 is not creating c++ project

Hello I wanted to create a project in UE4.10 with basic c++ code. But when it comes to create it, UE gives me an error:
The project could not be compiled. Would you like to open it in Visual Studio? Running E:/Program Files (x86)/Epic Games/4.10/Engine/Binaries/DotNET/UnrealBuildTool.exe MyProject Development Win64 -project="C:/Users/allst/Documents/Unreal Projects/MyProject/MyProject.uproject" -rocket -editorrecompile -progress -noubtmakefiles -2015 #progress push 5% Parsing headers for MyProjectEditor Running UnrealHeaderTool "C:/Users/allst/Documents/Unreal Projects/MyProject/MyProject.uproject" "C:\Users\allst\Documents\Unreal Projects\MyProject\Intermediate\Build\Win64\MyProjectEditor\Development\UnrealHeaderTool.manifest" -LogCmds="loginit warning, logexit warning, logdatabase error" -rocket -installed Reflection code generated for MyProjectEditor in 17,8672852 seconds #progress pop Performing 7 actions (2 in parallel) [2/7] Resource PCLaunch.rc E:\Program Files (x86)\Epic Games\4.10\Engine\Source\Runtime\Launch\Resources\Windows\PCLaunch.rc(10) : fatal error RC1015: cannot open include file 'windows.h'. [3/7] Resource ModuleVersionResource.rc.inl E:\Program Files (x86)\Epic Games\4.10\Engine\Source\Runtime\Core\Resources\Windows\ModuleVersionResource.rc.inl(3) : fatal error RC1015: cannot open include file 'windows.h'. PCH.MyProject.h.cpp E:\Program Files (x86)\Epic Games\4.10\Engine\Source\Runtime\Core\Public\HAL\PlatformIncludes.h(5): fatal error C1083: Cannot open include file: 'new': No such file or directory -------- End Detailed Actions Stats ----------------------------------------------------------- ERROR: UBT ERROR: Failed to produce item: C:\Users\allst\Documents\Unreal Projects\MyProject\Binaries\Win64\UE4Editor-MyProject.dll Total build time: 90,64 seconds
I had VS 2013 pro, but I was asked to install VS 2015 community, what I have done, but problem is still persisting. Have you any ideas what should be done now? I will be gratefull for any advice. Have a nice day!
Please verify that "Common Tools for Visual C++ 2015" was selected when installing Visual Studio 2015. It will not automatically install, you need to do a custom install for that.
It appear to be a known problem while running Unreal Engine prior to 4.12.5 with Visual Studio Community 2015 with Update 3.
Assuming that you already have Common Tools for Visual C++ 2015 installed.
You can check if you are running VS2015 with Update 3 by going to:
Visual Studio 2015 > Help > About Microsoft Visual Studio
Solution 1: Update Unreal Engine > 4.12.5
Updating your Unreal Engine to version above 4.12.5
Go to
Epic Game launcher > Unreal Engine > Library > Engine Version to update the engine.
Solution 2: Resintall VS2015 without Update 3
Follow the instruction from Infected_Post here.
Below is what he has posted:
Completely uninstall visual studio
Use the Extra visual studio uninstall cleaner. Found on
github > Microsoft/VisualStudioUninstaller/releases
Delete the remaining Visual Studio installation folder.
Do a restart and this machine should be ready for a clean installation
Download the Visual Studio 2015 installer without any updates: https://www.microsoft.com/en-us/download/details.aspx?id=48146
Now make sure you do a custom installation and deselect update 3!!!
Once the installation is finished you need to generate visual studio project files for your unreal projects.

Marmalade ErrorCode 4 while building mkb project

I've got a project from my teacher, that I should run in the Marmalade Hub. I've imported this project en tried to run it. At first I got an error with the error code 7.
error: Visual Studio 2013 Express Windows Desktop requested but not found instal
led.
FAILED (error code=7)
I've fixed this problem to change the C++ Development (IDE's and Compilers) from 'Visual studio Express 2013 Windows Desktop' to 'Visual Studio 2013' (see image below). I did this change, because I do have 'Visual Studio Proffesional 2013 for Windows Desktop' and not 'Visual Studio Express 2013 for Windows Desktop'. 'Visual Studio 2013 Proffesional 2013 for Windows Desktop' doesn't exist in the drop down.
I tried again to run the project (see image below) and I did get another error with the error code 4:
-- Visual Studio Output --
1>------ Build started: Project: minimal_marmalade_vc12, Configuration: x86 Debu
g Win32 ------
1>LINK : warning LNK4075: ignoring '/INCREMENTAL' due to '/FORCE' specification
1>LINK : fatal error LNK1181: cannot open input file 'cgl_d.lib'
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
-- End Visual Studio Output --
error: build failed: '['C:\\Program Files (x86)\\Microsoft Visual Studio 12.0\\C
ommon7\\IDE\\devenv.exe', 'minimal_marmalade_vc12.sln', '/build', 'X86 Debug', '
/out', 'vs_output_11728.log']' (1)
FAILED (error code=4)
I hope you guys (or girls ;) ) can solve this problem. Thanks!
Maybe that your project uses the library Core Media Library. Check whether used somewhere in the code header file cgl.h If so, then reinstall Core Media Library Instalation instructions you find in this guide

Getting "Cannot open include file: 'atlbase.h': No such file or directory" error

I am swapping machines (between two Windows 8.1 laptops) and have just loaded the project I'm working on from TFS. On one machine it compiles, on the other it does not and gives the first error
error C1083: Cannot open include file: 'atlbase.h': No such file or directory
On both laptops I am running Visual Studio Ultimate 2013. On the first laptop I've checked to see where it is picking up atlbase.h and it is from C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\atlmfc\include i.e. from the Visual Studio 2012 installation directory. On the new machine I do not have Visual Studio 2012 installed so the directory C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\atlmfc\include does not exist.
Other people have similar problems (e.g. Ramilol's question) because they are using Visual Studio Express. I am using Ultimate.
It could be an environment variables problem (as suggested by raj raj) but my include directory paths under VC++ Directories are $(VCInstallDir)include;$(VCInstallDir)atlmfc\include;$(WindowsSDK_IncludePath) as required.
My general question is "how do I fix this?" but I'd also be interested to know how I check and set the value of $(VCInstallDir) since C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\atlmfc\include does have atlbase.h in (so I am flummoxed as to why it is not picked up).
========== EDIT 1: Rewording ==========
Let me have another go at wording this question.
I have loaded a Visual Studio 2013 project onto a new build laptop from TFS. It will not build and gives errors like error C1083: Cannot open include file: 'atlbase.h': No such file or directory. The file atlbase.h is present on the new machine, in the directory C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\atlmfc\include.
In my project's properties my include directory paths under VC++ Directories are $(VCInstallDir)include;$(VCInstallDir)atlmfc\include;$(WindowsSDK_IncludePath)
How do I check what those macros are set to, and if they are not where atlbase.h is (i.e. C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\atlmfc\include) how do I fix that?
========== EDIT 2: Microsoft Visual C++ Redistributables installed ==========
Responding to jp2code's answer the machine that works and the one that does not have a similar array of Microsoft Visual C++ Redistributables installed as the following screenshot shows (the working machine's on the left):
========== EDIT 3: Environment variables ==========
In his answer, pje explains how to look up the environment variables. %VCInstallDir% is correctly set to C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\ But if I right click on the line #include <atlbase.h> I get this error which suggests that despite %VCInstallDir% being correct, that is not where VS is looking:
========== EDIT 4: Platform toolkit setting ==========
Another possibility is the Configuration Properties | General | Platform Toolset project setting, suggested by manuell in the comments and Michael Burr in his answer. For the project it is set to set to Visual Studio 2012 (v110) but the only other option listed in the drop-down is v110_wp80, which, when selected, becomes Windows Phone 8.0 (v110). If I hand edit the .vcxproj file in notepad and reopening the project in Visual Studio Ultimate 2013 the property page now lists the Platform Toolset as Visual Studio 2013 (v120) (not installed).
If I start a new C++ Windows Store project I can set Platform Toolset to Visual Studio 2013 (v120) without issue, in fact it is the only option listed in the drop-down. (N.B. The new project has Target Platform Version set to 'Windows 8.1', and it is greyed out, so I cannot change it, while the failing project has it set to Windows 8.)
========== EDIT 5: Entire project settings file ==========
In the comments Michael suggests that "maybe posting the .vcxproj somewhere (like as a gist on github) might be helpful". I have posted it here.
========== EDIT 6: Uninstalling and reinstalling Visual Studio 2013 Ultimate ==========
Has no effect, the same error recurs.
On the new machine I do not have Visual Studio 2012 installed
Well, look no further, that's your problem. Your project targets the VS2012 toolset to build a Store project that runs on Windows 8.0. You can still open it in VS2013 but it can only be built if you have VS2012 installed as well. In other words, you must have the v110 toolset available on the machine. You don't.
Short from installing VS2012, you will have to re-target to 8.1 to get it to build with the VS2013 toolset (v120). Right-click the Solution node in the Solution Explorer window and select "Retarget Windows Store projects to Windows 8.1".
Do fret a bit about that laptop, it remembers too much about VS2012. Sounds like it had it once installed but it wasn't uninstalled properly.
If you want to see the value of $(VCInstallDir) or any other Visual Studio macro, then open the Developer Command Prompt for VS2013 (this should have installed with your VS 2013 install). In the prompt type: echo %VCInstallDir%. This will print the current value of the $(VCInstallDir) macro. If you want to change this to a different directory, then type set VCInstallDir=<directory path>, where <directory path> is the path to your desired directory (presumably C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\atlmfc\include in your case).
Hope this helps, cheers!
------edit-------
As a side note, it is possible that these macros were imported with the 2012 project that you were trying to load and compile with 2013. If it turns out that it was your $(VCInstallDir) macro that was wrong, then that would explain why.
Check that the "Configuration Properties | General | Platform Toolset" project setting is:
Visual Studio 2013 (v12)
and not something like "Visual Studio 2012 (v110)
Possible solution
Get Process Monitor
Filter for atlbase.h
this way you will know exactly where Visual Studio is looking for atlbase.h. Process monitor will show you the failed file-open attempts.
At this point you will be able to solve the problem by
make symbolic links (messy)
fix the include directory paths (better)
Update
Here is how you filter for file operations:
Don't forget to click Add after setting the filter parameters.
Check to see that both machines have the same versions of C++ Redistributable installed.
It is worth a shot, and will be easy to check.

Visual Studio 2010 Professional: Cannot find include file "new.h"

So I just got the Visual Studio 2010 Professional, I created a simple mfc application, added some code and did not change any of the project settings. When I try to compile it I got this errer:
1>------ Build started: Project: cadmenu, Configuration: Release Win32 ------
1>Build started 10/15/2013 3:44:26 PM.
1>InitializeBuildStatus:
1> Touching "Release\cadmenu.unsuccessfulbuild".
1>ClCompile:
1> stdafx.cpp
1>C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\atlmfc\include\afx.h(54): fatal error C1083: Cannot open include file: 'new.h': No such file or directory
1>
1>Build FAILED.
1>
1>Time Elapsed 00:00:00.06
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
This also happens if I create a new mfc app and do not add any code. I searched the entire computer, there is no new.h.
I understand that this is because the new.h file is not in the include directory, but this does not make any sense because I just did a complete install of visual studio 2010 professional. I tried uninstall, deleting all Visual Studio files and then re-install it but the problem persists. Can anyone tell me what is going on and how can I fix this? Thank you very much!
I'm using Windows 8 on a 64-bit machine. I tried Googling this problem all day and no good result.
I've just installed VS2015 and had the same problem. It seems that new.h used to live off the VC folder (e.g. C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\include) and now lives in the SDK folder (e.g. C:\Program Files (x86)\Windows Kits\10\Include\10.0.10150.0\ucrt). If you include this in your list of include folders it will compile past this point.
Just had this problem when trying to build with VS2017 Build Tools, too...
Solved it by adding the package "Windows Universal CRT SDK" to the install manually.
Right click on your project, then go to Properties, go to Configuration Properties, VC++ Directories, and in the Include Directories: $(VCInstallDir)include;. That is if you have the new.h in the directory specified, ie your installationDir\include
For me, it was because my solution had project build targets referring to the Windows SDK 10.0.10240, but the Visual Studio 2017 installer had, during a mere upgrade of Visual Studio, promptly removed the 10240 SDK as well as the Windows 8.1 SDK which my solution also needed.
I had to go to Invidual Components in the installer and manually re-check the Windows SDK 10.0.10240 and Windows 8.1 SDK, and now I got 3 GB worth of files back again.
Lesson learnt: The Visual Studio 2017 installer can do much more than just upgrade, if you let it "upgrade" to another minor release.
I can also recommend verifying so that the Windows Universal C Runtime (UCRT) is checked since it seems to reside under the ucrt subfolder.
This problem happened to me after importing an old VS2003 solution into VS2017.
To fix it, I had to change "Windows SDK version" in project settings > "Generic" to the latest "10.x.x.x" version available from the drop-down list.
I had the same problem, and i solved it by removing all "Microsoft Visual c++ Redistributable" installations and after that, repairing the VS installation.
Try to install VS2010 SP1, it should help