Published on February 3, 2018 by ProgrammingKnowledge

In this video I am going to show, How to Set Up C++ Development With Visual Studio Code on Windows 10. We will use MinGW with VS code as our compiler and debugging tool. So First I will show How to install mingw. The we will see how to create, build and compile our first C++ Program on VScode.

With an updated VS Code you can do it in the following manner:

Hit (Ctrl+P) and type:

ext install cpptools
Open a folder (Ctrl+K & Ctrl+O) and create a new file inside the folder with the extension .cpp (ex: main.cpp):

Type in your code and hit save.

Press (Ctrl+Shift+P and type, Configure task runner and then select other at the bottom of the list.

{
“version”: “2.0.0”,
“tasks”: [
{
“label”: “build hello world”,
“type”: “shell”,
“command”: “g++”,
“args”: [
“-g”, “helloworld.cpp”
],
“group”: {
“kind”: “build”,
“isDefault”: true
}
}
]
}
Hit (Ctrl+Shift+B to run Build task. This will create the .obj and .exe files for the project.

For debugging the project, Hit F5 and select C++(Windows).

In launch.json file, edit the following line and save the file:
Below is an example using the MinGW GDB debugger:

{
“version”: “0.2.0”,
“configurations”: [
{
“name”: “(gdb) Launch”,
“type”: “cppdbg”,
“request”: “launch”,
“program”: “${workspaceFolder}/a.exe”,
“args”: [],
“stopAtEntry”: false,
“cwd”: “${workspaceFolder}”,
“environment”: [],
“externalConsole”: true,
“MIMode”: “gdb”,
“miDebuggerPath”: “C:\mingw\bin\gdb.exe”,
“setupCommands”: [
{
“description”: “Enable pretty-printing for gdb”,
“text”: “-enable-pretty-printing”,
“ignoreFailures”: true
}
],
“preLaunchTask”: “build hello world”
}
]
}

Hit F5.

————————-Follow——————-
My Website – www.codebind.com
My Blog – goo.gl/Nd2pFn
My Facebook Page – goo.gl/eLp2cQ
Google+ – goo.gl/lvC5FX
Twitter – twitter.com/ProgrammingKnow
Pinterest – goo.gl/kCInUp
Text Case Converter – goo.gl/pVpcwL
Epoch Timestamp Converter – goo.gl/Zedjo5
Decimal – Binary – Hexadecimal Converter – goo.gl/rkX3JE
8-bit Checksum Calculator – goo.gl/inxvIT
————————-Stuff I use to make videos ——————-
Stuff I use to make videos
Windows notebook – amzn.to/2zcXPyF
Apple MacBook Pro – amzn.to/2BTJBZ7
Desktop – amzn.to/2zct252
Microphone – amzn.to/2zcYbW1
notebook mouse – amzn.to/2BVs4Q3

Leave a Reply

62 Comments on "Set Up C++ Development With Visual Studio Code on Windows 10"

Notify of
avatar

Jon Can't Even
Guest
Jon Can't Even
2 days 7 hours ago

I am still seeing "cannot open source file "bits/c++config.h" (dependency of "iostream")" unfortunately, and my …erties.json file is identical. Could anyone help with this issue?

Magic Cheese
Guest
Magic Cheese
5 days 2 hours ago

i can't watch this video without sleeping

Phaus Lex
Guest
Phaus Lex
5 days 12 hours ago

thanks heaven you uploaded this video, it's very helpful

ARTHUB
Guest
ARTHUB
6 days 1 hour ago

update ur windows

MM
Guest
MM
8 days 19 hours ago

Wtf is this? My brain is melting slowly.

Deepa Shenoy
Guest
Deepa Shenoy
10 days 1 hour ago

Thank you for the video. It is explained very well.

xpl2008
Guest
xpl2008
13 days 4 hours ago

I could not get it to work. In Problems tab i get 2 errors. 1. 'cout' : undeclared identifier and 2. 'system': identifier not found . Eventually i gave up and i am using online compilers.

Tom Burk
Guest
Tom Burk
16 days 2 hours ago

This is a great tutorial on a tricky process! Many of us used to Unix or Linux are horrified when we see the Vscode process for running C++. It seems so awkward at first to those used to a command line. But tasks.json and launch.json, thanks to your fine tutorial, I now realize, are perfectly good methods for issuing commands and starting a debugger. And your clear presentation of adding the paths to the compiler in the environment variables and the Windows configuration makes these critical steps super easy! Excellent stuff!

LawZist
Guest
LawZist
16 days 7 hours ago

Why not use .runner extension? btw great video!

Viral Mistry
Guest
Viral Mistry
18 days 20 hours ago
1 2 3 5
wpDiscuz