Developing C++ with Visual Studio Code
Tags: programming, cpp, visualstudiocode
Published: 2018-08-01 14:44:59

---
title: Developing C++ with Visual Studio Code
published: true
description: 
tags: #programming #cpp #visualstudiocode
---

Welcome to my first post! I will be showing you how I develop C++ using [Visual Studio Code](https://code.visualstudio.com/) along with the [C++](https://marketplace.visualstudio.com/items?itemName=ms-vscode.cpptools) and [Easy C++ Projects](https://marketplace.visualstudio.com/items?itemName=ACharLuk.easy-cpp-projects) extensions.


## Downloading Visual Studio Code

First we will need a code editor or IDE, I personally like Visual Studio Code (VSC for short) because it is lightweight like Sublime, but has some of the features I like from IDEs, specially Intellisense. You can download Visual Studio Code [here](https://code.visualstudio.com/), you will land on a page like this:
![](https://raw.githubusercontent.com/acharluk/UsefulStuff/master/programming/C++/images/1/1_vscode_website.png)
Click the download button and wait a few seconds for the download to start.

---

## Setting up VSC for C++ development

The first time you open VSC you will see a welcome window. VSC has a very simple layout: a bar on the left with 5 buttons (File explorer, Find, Git integration, Debug, Extensions), a status bar on the bottom and a window with tabs for the editors. Click the last button to open Extensions:
![](https://raw.githubusercontent.com/acharluk/UsefulStuff/master/programming/C++/images/1/2_searching_extensions.png)

To develop C++ we will install two extensions, the first one is C/C++, which is already shown in the last figure, to install it just click the green button that says `Install`:
![](https://raw.githubusercontent.com/acharluk/UsefulStuff/master/programming/C++/images/1/3_cpp_extension_install.png)

Then we will search for "easy c++" and then install the extension called "Easy C++ Projects"
![](https://raw.githubusercontent.com/acharluk/UsefulStuff/master/programming/C++/images/1/4_easy_cpp_extension_install.png)

---

## Environment setup finished

After installing the extensions, a blue button will appear saying `Reload`, clicking it will reload the window and activate the extensions we just installed, as shown here:
![](https://raw.githubusercontent.com/acharluk/UsefulStuff/master/programming/C++/images/1/5_extensions_installed.png)

Good job! Now we have an environment for depeloping our first C++ project!

---

# Creating our first C++ project with Visual Studio Code!

After setting up VSC for C++ development, we just need to create a new project! This is done in a few steps:


## Creating a folder for the project

To set the folder for the project, go to File > Open folder (or press [Ctrl+K Ctrl+O]), a dialog like this will pop up:
![](https://raw.githubusercontent.com/acharluk/UsefulStuff/master/programming/C++/images/2/1_opening_working_folder.png)

Create a new folder and press "Select folder", the dialog will close and the window will reload and open the folder we have created.

---

## Creating a C++ project

Press F1, a little window will appear with lots of different commands, search for "c++" and click "Create new C++ project":
![](https://raw.githubusercontent.com/acharluk/UsefulStuff/master/programming/C++/images/2/2_creating_cpp_project.png)

Now we will be asked what compiler we want to use, look the Easy C++ extension page for information on how to setup a compiler for your operating system. I will use Windows Subsystem for Linux.
![](https://raw.githubusercontent.com/acharluk/UsefulStuff/master/programming/C++/images/2/3_creating_cpp_project_2.png)

![](https://raw.githubusercontent.com/acharluk/UsefulStuff/master/programming/C++/images/2/4_compiler_setup.png)

---

## Code!

Now that we finished the creation step, VSC will generate the project structure for us, and open `main.cpp` with some example code:
![](https://raw.githubusercontent.com/acharluk/UsefulStuff/master/programming/C++/images/2/5_main_cpp.png)

To test that the project works press the `Build & Run` button on the status bar, a terminal will open and it will compile and execute our program for the first time!
![](https://raw.githubusercontent.com/acharluk/UsefulStuff/master/programming/C++/images/2/6_first_run.png)