Code360 powered by Coding Ninjas X Naukri.com. Code360 powered by Coding Ninjas X Naukri.com
Table of contents
1.
Setup of Visual Studio Code for C++
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: Mar 27, 2024
Easy

Visual Studio Code Setup for C++

Author Ankit Mishra
0 upvote
Leveraging ChatGPT - GenAI as a Microsoft Data Expert
Speaker
Prerita Agarwal
Data Specialist @
23 Jul, 2024 @ 01:30 PM

Setup of Visual Studio Code for C++

In this article, we will understand how to do the complete setup for using C++ in VS code editor. So let’s begin with the Setup for C++. For doing the setup, we need a compiler, text editor, and operating system on a PC installed. So let's start the discussion on the Setup on VS Code.

VSCode is a text editor that helps developers and version control systems work together. It gives users the tools they need to create hassle-free codes. Visual Studio Code is available for download and installation from visualstudio.com.

 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++.

Get the tech career you deserve, faster!
Connect with our expert counsellors to understand how to hack your way to success
User rating 4.7/5
1:1 doubt support
95% placement record
Akash Pal
Senior Software Engineer
326% Hike After Job Bootcamp
Himanshu Gusain
Programmer Analyst
32 LPA After Job Bootcamp
After Job
Bootcamp

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 extensively discussed the installation of C++ and Working With Visual Studio Code and how everything works with ease using the extensions.

Also check out this article - Pair in C++

Recommended Readings:

Refer to our guided paths on Coding Ninjas Studio 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.

Do upvote our blog to help other ninjas grow.

Happy Learning!

Live masterclass