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

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

Notify of
avatar

serpathius
Guest
serpathius
21 days 8 hours 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
22 days 13 hours 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
26 days 8 hours 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
1 month 1 day ago

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

Sammi Turner
Guest
Sammi Turner
1 month 4 days ago

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

Emad Saeed
Guest
Emad Saeed
1 month 6 days ago

thanks man, worked like a charm

TheGeeksHelp
Guest
TheGeeksHelp
1 month 8 days ago

which screen recorder you are using can you tell me ?

Yousef Saber
Guest
Yousef Saber
1 month 15 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
1 month 16 days ago

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

1SoldierofPeace
Guest
1SoldierofPeace
1 month 17 days ago

In the task file under "args", could you say "*.cpp" to set any c++ program or does it have to be the specific filename

Yousef Saber
Guest
Yousef Saber
1 month 13 days ago

no you have to write "main.cpp" for example and any header file "header.h" in order for it to work

1 2 3 7
wpDiscuz