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

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

Notify of
avatar

Tran Quang
Guest
Tran Quang
28 days 10 hours ago

This is life saver for me. Exactly what ive been looking for to deal with C programming with vs code and this contains all the things that i need to build and debug my C program. great thanks.

Vishal Rathod
Guest
Vishal Rathod
28 days 19 hours ago

really helpful, just followed each & every step and got succeed…thanx a lot..keep up the good work.

Tabet
Guest
Tabet
1 month 10 hours ago

Nice tutorial, man. The "Oke" was the best

Jiaming Yi
Guest
Jiaming Yi
1 month 3 days ago

Thanks a million! Very useful!

Jon Can't Even
Guest
Jon Can't Even
1 month 9 days 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?

Ashish Mishra
Guest
Ashish Mishra
7 days 23 hours ago

just save your work that you had been created until now and restart VS code with run as administration option it will resolve the problem

Vikramjit Roy
Guest
Vikramjit Roy
1 month 6 days ago

I am facing the same error. I think in the video the iostream still has green line after he changes in c_cpp_properties.json which might be due this error.

Magic Cheese
Guest
Magic Cheese
1 month 12 days ago

i can't watch this video without sleeping

Phaus Lex
Guest
Phaus Lex
1 month 12 days ago

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

ARTHUB
Guest
ARTHUB
1 month 13 days ago

update ur windows

MM
Guest
MM
1 month 16 days ago

Wtf is this? My brain is melting slowly.

Deepa Shenoy
Guest
Deepa Shenoy
1 month 17 days ago

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

wpDiscuz