Having trouble with setting up C++ in Visual Studio - c++

I'm getting a common error on the issue that I'm having but nothing has worked:
1>C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.32.31326\include\yvals.h(12,10): fatal error C1083: Cannot open include file: 'crtdbg.h': No such file or directory
I've been told to download the C++ dev kit again, the Windows SDK again, Reset my PC after download and manually change the path inside the file that can't find it.
As it turns out the file exists (and the Windows SDK too, I assume), Visual studio is just looking for it in the wrong spot, So I figure this is a setup issue. It exists in this location C:\Program Files (x86)\Windows Kits\10\Include\10.0.19041.0\ucrt. You could say why not just manually link to it? I have but then another file can't be found, so I change that and then another one can't be found and so on. I'd appreciate the help as this is the reason I get scared to use Visual Studio and go back running to Code, thank you!

Does this issue also occur if I create an empty C++ project and build it? If it works fine, this issue is more relevant to your current project.
Please check the target platform version of your project. Right click the project name and select ‘Properties’—‘Configuration Properties’—‘General’— ‘Windows SDK Version’ like the following, and select the Windows 10 SDK to have a try.
You could also refer to the method in this issue.
(PS:You need to make sure that the SDK you install is consistent with the operating system, for example if you use Win 11 then you should install the Windows 11 SDK.)

Related

visual studio unable to find assert.h

I'm a first year at uni and I just got my new laptop. I downloaded Visual Studio 2017 and pulled my solution repo. However, I'm having some issues because it appears that a lot of the files I had on my previous computer were not downloaded in the installation of VS. My university wifi is slow and I don't want to re-download if I don't have to. I followed the previous steps I took to download VS 2017 on my old computer. Yet, I'm getting errors like:
cannot open source file "assert.h"
cannot open source file "errno.h"
cannot open source file "float.h"
cannot open source file "corecrt.h"
cannot open source file "stddef.h"
cannot open source file "stdio.h"
(among 20+ others)
If I right-click and choose the "Open document" on the line with the error, I get the message:
File '_______.h' not found in current source file's directory or in build system path
However, if I go to my include paths, I can find files like:
cassert.h
cerrno.h
ostream.h
but none of the ones that I'm told are missing.
Mainly, I'm wondering if there is a directory with this files I just need to add to the include directory or whether I just need to admit defeat and reinstall.
Thanks for the help, I welcome editing as I'm sure I've messed things up. I'm new to this.
Cheers,
Caleb
Using VS2017 I was able to resolve this same issue by:
Right click on solution
Selecting 'Retarget Solution'
Selecting an SDK from the Windows SDK Version dropdown
Clicking OK button
Your Visual Studio 2017 installation is probably missing the C packages (they are not automatically included with the Desktop development with C++ workload).
To install it, start the Visual Studio Installer, go to Individual components, and check Windows Universal C Runtime:
I think this component is also automatically marked for installation when adding the Linux development with C++ workload.
I solved the problem by uninstalling my original installation of Visual Studio (2019 version), then reinstalling and including the workload Desktop Development with C++.
In contrast to the above solutions, I did not need (and it did not help) to add the Windows Universal C Runtime.

How do I alter the full path of visual studio project so I can use it on multiple computers?

So for a class we have a couple of programs where we are using opengl. To make setup easier we started by cloning glitter https://github.com/Polytonic/Glitter. I then compliled it according to the instructions for visual studio 2017 and added my code to the project I am working on. I did this on my desktop computer but saved the files in onedrive. When I open the same project on my laptop and try to build the project I get the error "the source directory D:/OneDrive/fall_2017/Glitter does not appear to contain CMakeLists.txt" and several other similar errors. On my laptop the directory to the files is C:/Users/Me/OneDrive/fall_2017/Glitter. The visual studio program lists the full path as D:/OneDrive/fall_2017/Glitter which is the path of the folder on my desktop.
Is there a way for me to change the filepath or is the issue with my cmake file? Do I have to rebuild it for every computer I use it on? I don't know a whole lot about visual studio so I don't know what I need to change to get this to work.
Turns out I have to rebuild on every computer. Thanks to those who left comments.

VS 2017: fatal error RC1015: cannot open include file 'winres.h'

I just downloaded Visual Studio 2017 and converted my dialog-based C++/MFC project with it (from Visual Studio 2008 SP1.) But then when I go to Resources it shows this error:
fatal error RC1015: cannot open include file 'winres.h'
And idea how to fix this?
I just also came across this issue. It seems my friend missed to push some VS 2017 meta file to the server. My quick solution is to change the Windows SDK version to match the Windows 10 OS version or below.
You can check your OS version from the cmd tool.
Jeff T. answer is great if you have a single project.
If you have many projects in which you have to change the target Windows SDK (or if you want to make sure they all match), you'll probably prefer to use the Retarget Solution button found when right clicking on the solution:
Then just select some Windows SDK version that you have installed, and apply it to all (or whatever) projects you need to change:
That list of Windows SDK versions will probably show some that don't really work. You might have to try.
The missing files are located in two directories:
C:\Program Files\Windows Kits\10\Include\10.0.15063.0\um
C:\Program Files\Windows Kits\10\Include\10.0.15063.0\shared
Add the two paths to project properties (Project >> ...Properties >> Configuration Properties >> VC++ Directories >> Include Directories).
You should install the framework MFC
For anyone who stumbles onto this question is in the same boat as me (tried all of the above with no luck)..
I just created a fresh project and created a resource immediately (no issue) and then went ahead and readded all the code / libs that were needed. A bit annoying but I'm sure it was a mistake I made while configuring the project settings
Hopefully this helps someone out
I my case, it was caused by wrong project configuration. Specifically Property Pages -> VC++ Directories -> Include Directories and there check Inherit from parent or project defaults.
Probably VS2017 fatal error RC1015 when attempting to add a new resource. fellow also got this error with VS2017.

can't setup openGL superBible examples due to problems finding Windows.h

I'm trying to compile the examples from the book OpenGL SuperBible 6th edition.
I got everything from their git repository and I'm trying to open it using Visual studio 2013 by opening the visual studio 2013 solution file that is included.
When I try building the main project inside "sb6_vs2013" It claims it can't find Windows.h : "Error 2 error C1083: Cannot open include file: 'windows.h': No such file or directory"
Now I tried to look at people's solutions on the internet and couldn't find anything helpful.
If I right click on the project and go to properties -> Configuration Properties - > VC directories I can see that it has the line:
$(WindowsSdkDir)\include
When I click on Macros I can see the path of WindowsSdkDir, its pointing to the right place where Windows SDK is, which in my case is: "C:\Program Files (x86)\Windows Kits\8.1" if I look at my file system in that folder and go to "\Include\um\" I can find Windows.h there, but for some reason visual studio 2013 fails to find it.
I thought it was due to bad installation and I even went as far as re-installing windows, visual studio and everything (it was time for that anyway) but nothing seems to fix this problem, even the new fresh installation didn't do the trick.
I'm not sure what else I can do to make this work.
Could someone help me solve this issue once and for all?
Eventually I managed to solved it, after the reinstall all the macros were correct I just need to check "inherit from parent on project defaults" checkbox and it did the trick

MSVCP100D.dll missing

When I try to debug my C++ application I get the error
The program can't start because MSVCP100D.dll is missing from your
computer. Try reinstalling the program to fix this problem.
I found someone with a similar problem here: Remote debugging C++ on the Windows Server 2008 platform with VS2010; MSVCP100D.dll missing however the solution given there doesn't seem to show up when I go to the solution properties.
Would reinstalling Visual Studio fix this problem?
Usually you don't want MSVCP100D.dll on your system. It's for debugging purposes only. If you get this error for your release build you must make sure that you didn't accidently add a 'Debug'-tagged Project Output to your setup project.
If you really need to debug your software on a remote machine, I suggest you do the following:
Create a new Setup project called 'CRTDebug100Setup' and add the following Merge Modules (found under C:\Program Files\Common Files\Merge Modules):
Microsoft_VC90_DebugCRT_x86.msm
policy_9_0_Microsoft_VC90_DebugCRT_x86.msm
Build, and deploy on your computer to be debugged!
Reinstalling Visual Studio fixed the problem.
This can also occur if Generate Debug info is not set to No
Configuration Properties -> Linker -> Debugging -> Generate Debug info
Followup on l33t's answer above (tried to revise it but it did not seem to appear).
Added later by gpicher 10 Jan 2012: I believe those .msm packages would be for a 9.x version of the DLL in question, not a 10.x version. I resolved a similar problem I had by making a setup project with Visual Studio 2010 installed on a 64 bit Windows installation, using the merge module Microsoft_VC100_DebugCRT_x86.msm in the folder C:\Program Files (x86)\Common Files\Merge Modules. There's a similar x64 version of the .msm if the application showing the error dialog is a 64 bit application. In this case a third party was providing me a debug build of their application in order to develop and test new plugin code against, so I couldn't change build settings, and wanted the debug functionality.
Find the Visual Studio 2010 install iso file.
Extract cab44.cab file from the ISO.
Then extract file "F_REDIST_DLL_APPLOCAL_msvcp100d_x86" from the .cab file using 7z.
Rename the file to msvcp100d.dll.
For x64 version. The cab file name is cab26.cab and the file name is F_REDIST_DLL_APPLOCAL_msvcp100d_x64.
For similar issue such missing msvcr*d.dll for another visual studio version. Here is the way I used to find the answer:
Find the Visual Studio ISO.
Extract all the .cab file.
7z.exe t *.cab > filelist.txt
gvim filelist.txt
searching for the interested file name. Hope this helps.