Visual Studio 2022 CMake Error The System cannot find the file specified - c++

I have updated the visual studio from 2019 to 2022, and trying to run CMakelists.txt
Ending up with the error "The system cannot find the file specified" for ninja.exe file,
weirdly it's looking for the file in 2019 folder instead of 2022.
I have already tried clearing cache and clean the building directory before I build with visual studio 2022.
Any help/suggestions are appreciated! Thanks!
Here is the screenshot of error:

Deleting 'out' folder and re creating solved for me

Related

Visual Studio 2019 does not open window with source file and does not position to line with error

There are some compile errors in Errors List after CMake project compilation.
Visual Studio 2019 does not open window with source file and does not position to line with error through double click on them.
Also Intellisense not working correctly.
How can i solve this problem?
Clean build project and delete folder .vs of your solution.
You can check the following link to know more about how to fix intellisense issues in Visual Studio: https://weblog.west-wind.com/posts/2018/Aug/07/Fixing-Visual-Studio-Intellisense-Errors

I just installed visual studio and ran into some errors specifically The WindowsSDKDir property is not defined. Some build tools may not be found

Just installed visual studio 2019 on windows 10, was using visual studio for the first time and ran into the following error, It's a basic hello world console program that I tried to run.
error C1083: Cannot open include file: 'corecrt.h': No such file or directory
1>Done building project "ConsoleApplication2.vcxproj" -- FAILED.
Severity Code Description Project File Line Suppression State
Warning MSB8003 The WindowsSDKDir property is not defined. Some build tools may not be found. ConsoleApplication2 C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Microsoft\VC\v160\Microsoft.CppBuild.targets 434
I tried searching for this error over YouTube and of course here, and also Microsoft's offical forum but couldn't find anything.
#include <iostream>
using namespace std;
int main()
{
cout << "Hello World!\n";
}
the code looks just fine.
I ran into the same issue today. It turns out I didn't check the Win10SDK to save disk space while installation.
Solution:
In VS, go Tools menu=>Get Tools and Features=>install the Windows 10 SDK(10.XX.XX.XX)
Once installed, launch VS and open your project, right-click your project(NOT Solution)->properties->General->Windows SDK Version, check the value should be 10.0 instead of blank.
Then the compiling just worked.
I've got the same issue and turned out that I haven't installed Windows SDK. It can be done by typing "Install Windows SDK" into visual studio's search prompt
I had same problem when I installed Visual Studio 2019 on Windows7 and opened project created in Visual Studio 2017 (witch wasn't installed on that machine).
To solve the problem I went to project Properties -> General -> Windows SDK Version
And changed it from 10 to 8.1.
I fixed this issue by repairing Windows SDK. Now it's working as expected.
Steps:
Go to Settings>Apps & Features.
Click on Windows Software Development Kit - Windows 10.0.18362.1
(Note: Version number might be different for you)
Click on Modify.
Select Repair from options.
Click Next.
Restart VS and try running your project.
I was just having thesame issue so I figured maybe the headers were in a different directory than where the program is searching. When I went looking for tge header files none existed. So the problem is probably with iostream not existing.

VCVARSALL.BAT for Visual studio 2017

What is the location of file:
VCVARSALL.BAT
for Visual studio 2017?
To summarize, sth along the lines of
"C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Auxiliary\Build\vcvarsall.bat" x64
or
"C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\Common7\Tools\vsdevcmd" -arch=x64
(try running it with -help)
My environment:
** Visual Studio 2017 Developer Command Prompt v15.0.26403.7
on Win10 x64
Hans Passant is right.
I had the same problem: no VCVARSALL.BAT for my VS2017 and no Build folder in Microsoft Visual Studio\2017\Community\VC\Auxiliary.
I have Visual Studio Community 2015 and 2017 installed on the same machine.
I didn't have Desktop development with C++ check in my installation. I installed it and the Build folder was created!
Now everything work great.
VS2017 has reworked its directory structure and filenames. You should look for the file 'vcvars.bat', which can be located in "..\Program Files (x86)\Microsoft Visual Studio\2017\EDITION\Common7\Tools\vsdevcmd\ext\vcvars.bat" (replace EDITION with the version of Visual Studio you use).
For simplicity, you can use "%VSAPPIDDIR%" in your call to point to the IDE folder where devenv.exe is located, and go back one folder to define your path to the batch file. For example:
call "%VSAPPIDDIR%..\Tools\vsdevcmd\ext\vcvars.bat"
The VC folder is within the Desktop development with C++ workload. Go to your add or remove programs and modify your Visual Studio 2017, and choose it as shown below:
click on Modify (or Install/Setup in other devices). Go check your folder *\Microsoft Visual Studio\2017\Community\VC\Auxiliary\Build* and you'll see the the vcvars64.bat.
I had the same problem - was fixed by removing and reinstalling latest version of microsoft office (2017-2019) resolved the issue. The folder should exist in your MS path automatically, if its not there, uninstall and redownload and install - on my system takes around 3 hours.

LNK1104 cannot open file '...lib.obj'

I'm trying to update Visual Studio 2012 C++ projects so that I can compile them in Visual Studio 2015 (Update 3). I've gotten it narrowed down to just one error in one project that I'm completely stumped on:
LNK1104 cannot open file 'C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\lib.obj'
I've installed all the C++ language options (they don't get installed by default) and even uninstalled and reinstalled Visual Studio.
That file doesn't exist in that directory, and it also doesn't exist in the Visual Studio 2012 directory either.
Anyone have any ideas on how to solve this?
The problem might be that you added something like "$(VC_LibraryPath_x86)xxxx.lib" to the Linker input additional dependencies. This goes wrong, resulting in the error. It should just be "xxxx.lib".
Check your path. If that's correct then make sure you've written xxx.lib rather than xxx

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.