Table of contents
1.
Introduction
2.
Is your PC Capable of Running Visual Studio?
2.1.
Begin Developing
3.
C++ Setup
4.
Add Extensions 
5.
Templates
6.
Setting up the Debugger
7.
Frequently Asked Questions
7.1.
What is Mingw?
7.2.
Why isn't my C++ programme running in Visual Studio Code?
7.3.
How to add C++ libraries to the Visual Studio Code?
7.4.
How to check that the C++ compiler is installed?
7.5.
Does Microsoft windows 10 comes with in-Built C++ compiler?
8.
Conclusion
Last Updated: Oct 25, 2024
Easy

Visual Studio Code Setup for C++

Author ANKIT MISHRA
0 upvote
Career growth poll
Do you think IIT Guwahati certified course can help you in your career?

Introduction

Visual Studio Code (VS Code) has quickly become one of the most popular code editors among developers, thanks to its lightweight design, robust extensibility, and support for multiple programming languages. For C++ developers, VS Code offers a streamlined yet powerful environment to write, debug, and manage projects with ease. However, configuring it for C++ development can require a few initial steps to ensure you have the tools, extensions, and settings needed to maximize productivity. In this blog, we'll walk you through setting up Visual Studio Code for C++ development from scratch.

Visual Studio Code Setup for C++

 Fibonacci Series in C++

Is your PC Capable of Running Visual Studio?

Check the system requirements before you start installing Visual Studio. These specifications will tell you if your computer is capable of running Visual Studio 2022.

Install the most recent Windows updates. These updates make sure your machine has the most recent security upgrades as well as the system components needed for Visual Studio. Then reboot the system, reboot guarantees that any pending updates or installs do not interfere with the Visual Studio installation.

Make some room, Run the Disk Cleanup software, for example, to remove unnecessary files and applications from your SystemDrive percent.

And then download the Visual Studio Code.

Install the Visual Studio setup program.

To install the Visual Studio Installer,

Run the bootstrapper file you downloaded. This new, lightweight installer comes with everything you'll need to set up and personalize Visual Studio.

Double-click on the bootstrapper that matches or is similar to one of the following files in your Downloads folder:

Visual Studio Community uses vs_community.exe, Visual Studio Professional uses vs_professional.exe, and Visual Studio Enterprise uses vs_enterprise.exe.

Select Yes if a User Account Control warning appears to allow the bootstrapper to start.

You will be asked to agree with all the Microsoft License Terms and the Microsoft Privacy Statement. Select Continue.

After the installer is installed completely, you can use it to customize your installation by selecting the workloads, or feature sets, that you want.

Begin Developing

  • Select the Launch option to begin developing with Visual Studio after the installation is complete.
  • Choose the Create a new project from the start menu.
  • Enter the type of app you want to make in the search box to view a list of available templates. The templates available are determined by the workload(s) you selected during installation. Choose various workloads to see alternative templates.
  • You can also use the Language drop-down list to narrow your search for a certain programming language. You can also use the Platform and Project type lists to refine your search.
  • You're ready to code now that Visual Studio has opened your new project.

Now let's move to set up the VS code for C++. You can also do a free certification of Basics of C++.

C++ Setup

  • Mingw-w64 can be downloaded from the SourceForge website. Visit to get the Windows Mingw-w64 installer. Go to Mingw-w64.
  • Start the installation program.
  • Select x86 64 for Architecture and then Next.
  • Add the path to your Mingw-w64 bin folder to the Windows PATH environment variable by using the following steps:
  • Run these commands in the command prompt to verify the installation.
    g++ –version
    gdb –version

For more guiding paths for the installation of Mingw, you can check out our blog here.

Add Extensions 

Competitive Companion: Competitive Companion is a browser plugin that parses and saves programming challenges from websites. Chrome and Firefox are both supported.

Competitive Programming helper: This VSCode extension performs the magic of launching test cases from files. Manually modify or add test cases. Download here.

C/C++ for Visual Studio Code: This is a supplemental extension. IntelliSense, debugging, and code browsing are all required. Download here.

Code Runner: (Optional) Without executing commands, run a code snippet or a code file in several languages. Get here.

Templates

You can use a snippet generator to make snippets for C++ in VS Code.

Select User Snippets under File > Preferences (ctrl + shift + p) and then the language to create or update your snippets. Use this fantastic service to turn your code into a snippet. Save the JSON configuration file with the snippet inside the curly braces. A comma should be used to separate different samples. Make a single huge template or create your own clever snippets for different algorithms.

Snippets are simple to utilize.

To use the snippet, press d and then tab.

Setting up the Debugger

Debugging can sometimes be difficult, mainly if the vast software contains runtime problems. Printing won't assist much in such circumstances. To save the day of hectic work, all you need is a debugger. Thankfully, VSCode includes a decent debugging interface.

After this, we are good to go to start the development and coding in C++ in Visual Studio Code.

Also, see Literals in C, Abstract Data Types in C++

Frequently Asked Questions

What is Mingw?

MinGW is a compiler system that compiles and links program for use on Win32 (Windows) platforms, based on the GNU GCC and Binutils projects. It includes compilers for C, C++, and Fortran, as well as other utilities. The "Minimalist GNU for Windows" project is referred known as "MinGW."

Why isn't my C++ programme running in Visual Studio Code?

You must manually enable read-write to remedy this. Go to File > Preference > Setting in VsCode. Find a checkbox by scrolling. Using the Terminal (Whether to run code in Integrated Terminal) Select the checkbox.

How to add C++ libraries to the Visual Studio Code?

Search for 'c++' in the Extensions view (Ctrl+Shift+X) to install the C/C++ extension. Install the compiler kit for Microsoft Visual C++ (MSVC). Open the Visual Studio Installer from the Windows Start menu if you have a recent version of Visual Studio and make sure the C++ workload is checked.

How to check that the C++ compiler is installed?

To see whether your machine has the C++ compiler installed, use "g++ –version" on the command prompt.

Does Microsoft windows 10 comes with in-Built C++ compiler?

Yes, It comes with a C++ compiler that may be run from the command line or through the integrated development environment (IDE).

Conclusion

In this article, we have discussed Visual Studio Code Setup for C++. With Visual Studio Code configured for C++ development, you now have a streamlined, customizable, and powerful environment ready to support your programming projects. From installing the right extensions to setting up debugging and managing build tasks, you've built a workspace that enhances productivity and simplifies the coding experience.

Also check out this article - Pair in C++

Recommended Readings:

Refer to our guided paths on Code360 to learn more about DSA, Competitive Programming, JavaScript, System Design, etc. Enrol in our courses, refer to the mock test and problems; look at the interview experiences and interview bundle for placement preparations.

Live masterclass