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

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

Notify of
avatar

Phaus Lex
Guest
Phaus Lex
2 months 8 days ago

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

ARTHUB
Guest
ARTHUB
2 months 8 days ago

update ur windows

MM
Guest
MM
2 months 11 days ago

Wtf is this? My brain is melting slowly.

Deepa Shenoy
Guest
Deepa Shenoy
2 months 12 days ago

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

xpl2008
Guest
xpl2008
2 months 15 days 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
2 months 18 days 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
2 months 18 days ago

Why not use .runner extension? btw great video!

Viral Mistry
Guest
Viral Mistry
2 months 21 days ago
Molivos
Guest
Molivos
2 months 21 days ago
I'd love to see a guide on using the visual c++ compiler and visual studio debugger, because in my opinion, as great as GNU's compiler and debugger are on unix systems, the microsoft c++ tools are far superior to MinGW or Cygwin. (For example try using stoi() in MinGW/Cygwin… what a disaster… There are many std:: functions which don't even work at all. Cygwin is for sure abandonware and MinGW never gets updated properly)edit: Also yes I realize I could just use Visual Studio, but I don't like it. VSCode is freaking awesome.edit2: Also a quick note, instead of doing… Read more »
Molivos
Guest
Molivos
2 months 20 days ago

Joku 1001 1000b nah I think I’m going to be using a cross between this and Casey Muratori’s setup (watch YouTube video “Handmade Hero Day 001”)

Joku 1001 1000b
Guest
Joku 1001 1000b
2 months 20 days ago

hey man, Did U find any good guide 4 this ?

avni sharma
Guest
avni sharma
2 months 21 days ago

No such file or directory error

wpDiscuz