How to Compile Your C++ Code in Visual Studio Code?

This article was written because we wanted to use a compiler for a C++ project. Everyone was using the IDEs for CodeBlocks and Visual Studio as usual. However, we were already used to utilizing Visual Studio Code for all of our programming requirements. Following that, I set out to discover a way to compile C++ directly in my VsCode Editor, which led to the production of this article. So, in this article, we’ll show you how to set up your compiler in Visual Studio Code.

Get a C++ compiler and install it: To download the MinGW setup file, go to www.mingw.org and click the “Download/Installer” link, or go here for Windows, here for Linux, and here for Mac. Install MinGW after it has finished downloading and wait for the “MinGW Installation Manager” to appear. When the “MinGW Installation Manager” appears, select mingw32-gcc-g++ from the drop-down menu and then “Mark for Installation.” Click “Installation > Apply Changes” in the top left corner of the menu. Allow time for the installation to complete. During this process, make sure you have a solid internet connection.

To add the location where the C++ compiler is located in your PATH environment variable, make the following changes: MinGW can be found under C:MinGWbin after it has been installed. You must now add this directory to your PATH environment variable. If you’ve been using computers for a time, you should already be able to do this.

In VS Code, install the Code Runner extension: Let’s install Code Runner now that we’ve completed setting up our compiler. Code Runner lets you run code snippets or entire code files in a variety of languages, including C, C++, Java, JavaScript, PHP, Python, Perl, Perl 6, Ruby, Go, Lua, Groovy, PowerShell, BAT/CMD, BASH/SH, F# Script, F# (.NET Core), C# Script, C# (.NET Core), VBScript, TypeScript, CoffeeScript, Scala, Julia, Crystal, OC. After installing restart Visual studio code. Open your C++ file in Visual studio code.

Use Code Runner to run your code:

  • Use Ctrl+Alt+N
  • Run Code after pressing F1.
  • In the editor context menu, right-click the Text Editor and select Run Code.

The code will be executed, and the results will be displayed in the Output Window. Using the ‘Ctrl+ shortcut, open the output window.

VsCode’s output terminal is read-only by default. It means that by default, you can’t utilize the terminal to take input. You must manually enable read-write to remedy this. The steps are as follows:

Go to File > Preference > Setting in VsCode.

Find the extensions section in the User tab on the left panel.

‘Run Code Configuration’ can be found by scrolling down.

Locate a checkbox by scrolling. In a terminal, run (Whether to run code in Integrated Terminal) Make a check in the box.

Final Thoughts: The advice in the above list is only a fundamental understanding of visual studio code. To become a visual studio champion, you can learn more related topics on YouTube. You can use Learn Tube by Career Ninja to enhance your YouTube learning. If you type up “Visual studio code tutorial” on Youtube, you’ll get a bunch of videos. A beginner will be confused because he or she will not know which video to select. Learn tube helps in the organization of YouTube search videos into a course style. So you don’t have to click on each and every video. It also provides online specialists who can assist you with your questions.

More from author

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Related posts

Advertismentspot_img

Latest posts

How to find Efficient Certifications for Working Professionals

Working professionals waste an average of 60–70% of certification course time relearning skills they already know. Efficient certifications for working professionals require three distinct...

Why Do Professional Certifications in 2026: The Post-AI Era Guide

Professional certifications in 2026 are non-negotiable for career survival because they bridge the critical skills gap in an AI-driven economy. Certified professionals earn 15–50%...

Online Certifications in India: The Complete Guide (2026 Edition)

The Complete Guide to Online Certifications in India helps professionals and students navigate the shift from traditional degrees to skill-based hiring. It involves identifying...

Want to stay up to date with the latest news?

We would love to hear from you! Please fill in your details and we will stay in touch. It's that simple!