Set Up C++ Development With Visual Studio Code on Windows 10 (VS Code)

ProgrammingKnowledge · 1.1M views · 2018 · 23:36

Open on YouTube

Testing, debugging & developer toolsC, C++, Rust, Go & systems languagestutorialdated

Why Stack Overflow recommends it

Stack Overflow users link it as a step-by-step walkthrough for getting VS Code, MinGW and g++ working on Windows, and many questions come from people who follow it and then hit PATH or include-path errors.

Recommended by 3 people across 3 different months, 2018 to 2020.

What it is

A 23-minute screen-recorded tutorial from ProgrammingKnowledge showing how to set up C++ development in Visual Studio Code on Windows 10. It covers installing MinGW, adding the cpptools extension, configuring tasks.json to build with g++, and setting up launch.json to debug with GDB.

What people said

Recommends Jerlam · 2018-08 · Stack Overflow · on “Visual Studio Code gives me "#include error detected" for C”

I found the solution thanks to this video on how to Set Up C++ Development With Visual Studio Code on Windows 10 (VS Code) [this video] . I launched MinGW Installation Manager and installed all the package from the Basic Setup . I added the path of the gcc compiler to my system´s environment variables: C:\MinGW\bin , in which is the gcc.exe . I opened the c_cpp_properties.json file and added different paths for the folders I want to include. So now my c_cpp_properties.json file looks like this: { "configurations": [{ "name": "Win32", "includePath": [ "${workspaceFolder}/**", "C:\\Program Files (x86)\\Windows Kits\\10\\Include\\10.0.10240.0\\ucrt", "C:\\Program Files (x86)\\Microsoft Visual Studio

Recommends informatik01 · 2019-06 · Stack Overflow · on “How to make initial setup for C++ development in VS Code?”

Here is quite up-to-date (at the moment of writing this) and thorough video tutorial: Set Up C++ Development With Visual Studio Code on Windows 10 [this video] .

Recommends C0DEWzard · 2019-07 · Stack Overflow · on “I have a build error with MinGW and VS Code "g++ not recognized as a cmdlet..."”

OK, I finally figured it out. What worked for me was adding the file path to the git bash shell (C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Git) to the System Environment Variables in the Control Panel (how to do that here [LINK] ). Make sure you also have the file path to the MinGW bin folder added to the Environment Variables as well (32bit installer: C:\MinGW\bin) (64bit installer: C:/mingw-w64/x86_64-8.1.0-win32-seh-rt_v6-rev0/mingw64/bin) Then, restart VS Code and build (Ctrl+Shift+B) again. Here's my final code for the .json files: c_cpp_properties.json: "configurations": [ { "name": "Win32", "includePath": [ "${workspaceFolder}/**" ], "defines": [ "_DEBUG", "UNICODE", "_UNIC

Cites AT759 · 2018-09 · Stack Overflow · on “Current Step: Building Tasks.json File”

I'm getting the error below while following this [this video] could someone help me figure out where I messed. { // See [LINK] // for the documentation about the tasks.json format "version": "2.0.0", "tasks": [ { "label": "echo", "type": "shell", "command": "g++", "args": ["-g", "main.cpp"], "group": { "kind": "build", "isDefault": true } } ] } Executing task: g++ -g main.cpp < 'g++' is not recognized as an internal or external command, operable program or batch file. The terminal process terminated with exit code: 1 Terminal will be reused by tasks, press any key to close it.

Cites allenlswain · 2019-07 · Stack Overflow · on “Debugger in Visual Studio Code displays cryptic error window”

I am trying to set up Visual Studio code for C++, as this video shows: [this video] . The problem I am running into is when configuring the debugger, I get a strange error window whenever I try to debug the project: "The preLaunchTask 'g++.exe build active file' terminated with error code 1". I have tried researching the error and nothing useful shows up. I have tried searching similar issues on StackOverflow without much luck. This is the code in my tasks.json file: { "version": "2.0.0", "tasks": [ { "label": "echo", "type": "shell", "command": "g++ -g main.cpp", "group": { "kind": "build", "isDefault": true } }, { "type": "shell", "label": "g++.exe build active file", "command": "C:\\MinGW\\bin

Cites C0DEWzard · 2019-07 · Stack Overflow · on “I have a build error with MinGW and VS Code "g++ not recognized as a cmdlet..."”

I am trying to set up build and run a c++ file in VS Code 2019. I am having build errors after editing the tasks.json file. The environment variable is set to g++ as it should be. So far, I have been following this tutorial [this video] . I attempted changing "command" to"C:\MinGW\bin\g++.exe" as recommended in a question thread on GitHub. However, because my c++ file is not in this file path, the program was not able to find it when I built the code. This is what the "command" portion of the tasks.json file should look like: "label": "build calculator adventure", "type": "shell", "command": "g++", "args": [ "-g", "-o", "Calculator-Adventure", "Calculator Adventure.cpp" ], "group": { "kind": "bui

Cites Iñigo Zepeda · 2020-01 · Stack Overflow · on “C++ set-up for Visual Studio Code not working”

So I am trying to code C++ on Visual Studio Code. I am following a tutorial from youtube. [this video] When I get to 9:58 is where I loose track. He gets a message on his #include that says edit "InlcudePath" settings I am doing the exact same thing as him and mine doesn't work. I am not sure why. I will show screenshots of his video and my code. I would greatly appreciate if someone could help me. Thanks! This is the youtube video's image [LINK] This is my image [LINK]