If you're doing C++ development for Windows, we recommend installing the Microsoft Visual C++ (MSVC) compiler.
To install MSVC, open the VS Code terminal (CTRL + `) and paste in the following command:
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.Windows11SDK.26100"
Note: You can use the C++ toolset from Visual Studio Build Tools along with Visual Studio Code to compile, build, and verify any C++ codebase as long as you also have a valid Visual Studio license (either Community, Pro, or Enterprise) that you are actively using to develop that C++ codebase.
Open the Developer Command Prompt for VS by typing '
developer' in the Windows Start menu.Check your MSVC installation by typing
clinto the Developer Command Prompt for VS. You should see a copyright message with the version and basic usage description.Note: To use MSVC from the command line or VS Code, you must run from a Developer Command Prompt for VS. An ordinary shell such as PowerShell, Bash, or the Windows command prompt does not have the necessary path environment variables set.
If you're targeting Linux from Windows, check out Using C++ and Windows Subsystem for Linux (WSL) in VS Code. Or, you could install GCC on Windows with MinGW.