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

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

Notify of
avatar

Felipe Roque
Guest
Felipe Roque
4 days 10 hours ago

if i do all of this stuff, probably i can code in C?

Suryansh Musical
Guest
Suryansh Musical
6 days 12 hours ago

it shows green under #include<iostream.h>please help

Rishi Gupta
Guest
Rishi Gupta
6 days 18 hours ago

i do not get green line when i write iostream ….how do i update path??? i even reloaded after i installed extension

Suryansh Musical
Guest
Suryansh Musical
8 days 16 hours ago

It do not create a.exe file It shows g++ is not recognize d

jkleczewski
Guest
jkleczewski
9 days 6 hours ago

I could not get the compile to work until I set my terminal to run c:\windows\system32\cmd.exe, powershell fails ever time with an error code 1… weird

Angus Ho
Guest
Angus Ho
15 days 1 hour ago

Nice tutorial, thanks a lot!!!

nishanth raikar
Guest
nishanth raikar
15 days 6 hours ago

Can u make a Ruby programming tutorial series?

wickedcat
Guest
wickedcat
15 days 12 hours ago

how to choose x64 or Win32 build ????

nbg
Guest
nbg
15 days 12 hours ago

There is a good extension in VS code called code runner marketplace.visualstudio.com/items?itemName=formulahendry.code-runner that auto-builds and runs code from multiple programming languages .

bhawesh gupta
Guest
bhawesh gupta
15 days 12 hours ago

g++ : The term 'g++' is not recognized as the name of a cmdlet,function, script file, or operable program. Check the spellingof the name, or if a path was included, verify that the path iscorrect and try again.At line:1 char:1+ g++ -g main.cpp showing me this error after creating tasks.json file and pressing cltr+shift+B

MMA TUBE 1
Guest
MMA TUBE 1
7 days 2 hours ago

put "command" : "C:\MinGW\bin\g++.exe" instead of "g++" and it will work 🙂

Suryansh Musical
Guest
Suryansh Musical
8 days 16 hours ago

Same problem

bhawesh gupta
Guest
bhawesh gupta
15 days 12 hours ago

sir please help me !!

wpDiscuz