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

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

Notify of
avatar

Magical Blitz
Guest
Magical Blitz
1 month 19 days ago

Is there a difference between MinGW and C/C++ by Microsoft?

Magical Blitz
Guest
Magical Blitz
1 month 19 days ago

Never mind I take that questions back.

serpathius
Guest
serpathius
1 month 24 days ago

I didn't get a green squiggly line and in the output I get .vscodeextensionsms-vscode.cpptools-0.17.5binMicrosoft.VSCode.CPP.Extension.exe failed.

Serge Lussier
Guest
Serge Lussier
1 month 25 days ago

Do you realize that you made a very big mistake at the includepath settings? ( I stopped to watch there, but I am sure you have fixed your newbie class mistake later because vscode would complain!! )

Mutabar Shah
Guest
Mutabar Shah
1 month 29 days ago

Thanks sir it works but i got an error in debbuger that invalid path and i think that the path which i have select is correct.

Suhail Ahmad
Guest
Suhail Ahmad
2 months 3 days ago

do i have to do this every time i create a new project folder to start a project

Sammi Turner
Guest
Sammi Turner
2 months 6 days ago

Awesome tutorial. Programming Knowledge is the Indian Bucky Roberts. Love it!

Emad Saeed
Guest
Emad Saeed
2 months 8 days ago

thanks man, worked like a charm

TheGeeksHelp
Guest
TheGeeksHelp
2 months 10 days ago

which screen recorder you are using can you tell me ?

Yousef Saber
Guest
Yousef Saber
2 months 18 days ago

thanks your steps works very well there is only one problem I can't include header files ?? I fixed this problem by adding the header files in the arg in task file the main reason why some people prefer VS Code over VS IDEis because VS Code is free and Open Source while the other costs money for commercial use

Raktim Haldar
Guest
Raktim Haldar
2 months 19 days ago

this is very helpful video. from last few days i was unable to set up VS Code. thanks

wpDiscuz