this has been an ongoing issue with vscode where I keep getting include errors, I've finally reached my tipping point
This is the basic "Hello World" c++ program, as usual, vscode is giving me nothing
[{
"resource": "/c:/Users/name/file.cpp",
"owner": "clang-tidy",
"code": "clang-diagnostic-error",
"severity": 8,
"message": "Error while processing",
"source": "C/C++",
"startLineNumber": 1,
"startColumn": 1,
"endLineNumber": 1,
"endColumn": 2,
"relatedInformation": [
{
"startLineNumber": 20,
"startColumn": 10,
"endLineNumber": 20,
"endColumn": 11,
"message": "'crtdbg.h' file not found",
"resource": "/C:/Program Files (x86)/Microsoft Visual Studio/2022/BuildTools/VC/Tools/MSVC/14.38.33130/include/yvals.h"
}
]
}]
This is being run on windows 10
I have tried brute forcing it through mingw installation, from mingw obtained from msys2 and these last 2-3 weeks trying to connect vscode to code::blocks just so that I can have a workspace I at least kind of understand.
This final attempt was done following the inbuild c++ tutorial where I install msvc using winget
winget install Microsoft.VisualStudio.2022.BuildTools --force --override "--wait --passive --add Microsoft.VisualStudio.Workload.VCTools --add Microsoft.VisualStudio.Component.VC.Tools.x86.x64 --add Microsoft.VisualStudio.Component.Windows10SDK"
I did manage to get it working with Code::Blocks, but only by the use of a tool that launches vscode at the current location, which is a little bit of progress in achieving C++ compatability, but after 4 years of trying it on and off, I doubt I can do this without external assistance.
I would first suggest installing with the BuildTools version of Visual Studio Installer (this takes care of installing any required workload dependencies). Here's the link: https://visualstudio.microsoft.com/downloads/#build-tools-for-visual-studio-2022. Make sure to check the "Desktop Development with C++".
To be able to use any of the MSVC BuildTools from the command line (both Command Prompt and Powershell), you need to invoke one of BuildTools environment setup scripts located under C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\VC\Auxiliary\Build\
. The script vcvars64.bat
will supplement the command line environment with the x64 host compiler tools targeting native x64 windows. This also applies to any static analysis tools: they rely on the same environment variables as the msvc compiler tools to deduce include paths, library paths and so on.
This is all explained on https://learn.microsoft.com/en-us/cpp/build/building-on-the-command-line?view=msvc-170
PS: The Visual Studio installer also creates some start menu shortcuts, and new Windows Terminal profiles that does this setup automatically.