How To Install VSCode For C++ On Windows

By bhagwatchouhan
How To Install VSCode For C++ On Windows

Visual Studio Code or VSCode is a cross-platform, lightweight editor and became popular in a very short span. It provides support for several programming languages. It also supports plugin development and there are several community-driven plugins available for it.

In this tutorial, we will discuss how to install and prepare Visual Studio Code or VSCode for C++ development on Windows. It provides several features for C and C++ development including IntelliSense, Syntax Highlighting, Bracket Matching, Snippets, Linting, etc.

It assumes that appropriate C++ compiler is already installed on the system. You may also be interested in How To Install MinGW on Windows to install MinGW or MinGW-W64 having C++ compiler.

 

Step 1: Download Visual Studio Code

We can download Visual Studio from the official download page. It provides options for Windows as shown in Fig 1.

Download Visual Studio Code

Fig 1

Click on the 64-bit installer option as highlighted in Fig 1. All the new systems support 64-bit. Choose your option according to system configuration. The version 1.37.1 gets downloaded while writing this tutorial.

 

Step 2: Install Visual Studio Code

In this step, we will install the Visual Studio Code downloaded by us in the previous step. Double click the installer to execute it. It will ask to accept the License Agreement as shown in Fig 2.

Acccept License Agreement

Fig 2

Accept the agreement and click on the Next Button. It asks to choose the installation directory as shown in Fig 3.

Visual Studio Code Install Location

Fig 3

Choose your preferred location and click on the Next Button. The installer will ask to configure Start Menu as shown in Fig 4.

Configure Start Menu

Fig 4

Now click on the Next Button to continue with the installation. The next screen provides additional configuration options as shown in Fig 5.

Additional Configuration Options

Fig 5

Click on the Next Button after choosing appropriate options. The next screen shows the configurations selected by us in the previous screens.

Installation Configurations

Fig 6

Click on the Install Button to start the installation. The installer will show installation progress and success as shown in Fig 7 and Fig 8 respectively.

Installation Progress

Fig 7

Installed Visual Studio Code

Fig 8

This is how we can install Visual Studio Code. After completing the installation, the installer will launch Visual Studio Code and shows the Welcome Screen as shown in Fig 9.

Welcome Screen

Fig 9

The Customize Section on the right-hand side shows that support for JavaScript is already installed by default and it shows options to install plugins for other languages and tools.

 

Step 3: Marketplace

You can see all the available plugins on the Marketplace dedicated for Visual Studio Code. Type C++ in the search box and click on the Search Button. The results should be similar to one as shown in Fig 10.

Visual Studio Code - C++ - Marketplace

Fig 10

We can also browse the available extensions within the IDE by clicking on View -> Extensions or press Ctrl + Shift + x. Enter C++ on the Search Box and hit Enter Key. It will show the same extensions list within the IDE as we saw on the Marketplace Page as shown in Fig 11.

VSCode - C++ - Extensions

Fig 11

 

Step 4: Install Extensions

We will install the most important extensions as part of this tutorial. Also, make sure that you are using the most recent version of MinGW or Microsoft C++ compiler.

C/C++ is the most important extension having IntelliSense, debugging and code browsing. Every C or C++ developer must install C/C++ plugin distributed by Microsoft for Visual Studio Code. Another popular extension is C/C++ Compile Run to compile and run single C or C++ files. The other extensions can be installed based on the requirements. Install the extension as shown in Fig 12 and Fig 13.

VSCode - C++ - Extension

Fig 12

VSCode - C++ - Compile Run

Fig 13

Also, install the Code Runner Extension as shown below.

VSCode - Code Runner

Fig - Code Runner

 

Step 5: Getting started with C++ - Hello World

In this section, we will create our Hello World project i.e. HelloCPP project and write and execute the first program using Visual Studio Code.

Click on File -> Open Folder or press Cntrl + K and Cntrl + O to open the File Chooser to select the project folder. It will open the selected folder as highlighted in Fig 14.

VSCode - C++ - Folder

Fig 14

Now click on the New File Icon as highlighted in Fig 15.

VSCode - C++ - File

Fig 15

Enter the file name as hello.cpp and hit the Enter Key. It will create the C++ file as shown in Fig 16.

VSCode - C++ - File View

Fig 16

Update the file and write the first program to print Hello World as shown in Fig 17.

VSCode - C++ - File Update

Fig 17

Now right-click the file and choose the option Run to compile, build, and execute the program as shown in Fig 18 and Fig 19.

VSCode - C++ - Run

Fig 18

VSCode - C++ - Output

Fig 19

 

Step 6: Getting started with C - Hello World

We can follow the same steps to create the file hello.c and update the program as shown in Fig 20.

VSCode - C - File

Fig 20

Now right-click the file and click on the Run option to compile, build, and execute it similar to C++ file.

This is how we can install Visual Studio Code for C/C++ development. We have also written our first hello world program for both C and C++ and executed the programs within the editor.

Share this blog:

Profile picture for user bhagwatchouhan
bhagwatchouhan