Press F5 or from the main menu choose Run > Start Debugging. Go back to helloworld.cpp so that it is the active file. "preLaunchTask": "g++ build active file",
"description": "Enable pretty-printing for gdb", Your new tasks.json file should look similar to the JSON below: In the dropdown, choose g++ build active file, which will build the file that is currently displayed(helloWorld.cpp in this case) in the editor.
Add a source code file(say helloWorld.cpp) from VS code and write your code in that file:Ĭout Configure Default Build Task.
Once these two extensions are installed, you will see the context in which the VS code is running is changed to in the status bar present at the bottom of Visual Studio. C/C++: C/C++ extension adds language support for C/C++ to Visual Studio Code, including features such as IntelliSense and debugging.
Inside the WSL command prompt, first run apt-get update to update the Ubuntu package lists just to avoid any issues because of out-of-date packages: Opening it will start the WSL command prompt. Just open the Microsoft Store and select your favorite Linux distribution(Ubuntu in my case).Īfter installation is completed, search for the Linux distribution which you installed in windows search(lets say Ubuntu). Install your Linux distribution of choice. Install Windows Subsystems for Linux(WSL) using the instructions from the official documentation here.
So I decided to prepare a compiled step-by-step guide for the complete process so that everything can be found at a single place. For that reason, I decided to get the debugger for C++ running on my Windows system.Īfter a lot of googling and reading a lot of articles on the same, I was finally able to debug my C++ code using VS Code on my Windows system but it took a lot of my time to work out the complete solution. Like a lot of other developers, I am a fan of dark-themes too, and using something like VS Code will give me more options to explore in dark themes. Although I could have used Codeblocks which supports debugging features on Windows platforms in this case, but I am not used to light-theme applications and I don't quite like the debugging interface it offers. The first one of those was setting up a debugger in Windows(Windows 10 in my case) was quite problematic when used for languages like C++. I thought it was a simple task when I was trying to debug my code for one of the problems for an online coding competition on codeforces but I found out a lot of blockers in front of me when I did it the very first time.
This article is about using VS Code for Debugging your C/C++ code on Windows(8/9/10).