DEV Community

vuthanhnam94
vuthanhnam94

Posted on

How to install C++ with Visual Studio Code

We need to download two things to run our C/C++ code.

MinGW compiler — To compile the code or simply translate it into machine-readable language.
Visual Studio Code — IDE in which we will write our program.
Downloading MinGW Compiler
Visit https://sourceforge.net/projects/mingw/ and click on download.
Open the mingw-get-setup.exe file and go with the default installation. After installation MinGW Installation Manager window will shows up.
MinGW Installation Manager

Click on the checkbox to the left of mingw32-gcc-g++ (I have already downloaded it that’s why it is showing a green box) . Select Installation > Apply Changes > Apply from the menu bar.
Installing compilers in MinGW Installation manager

Editing PATH environment variable
We need to include the directory C:\MinGW\bin in our system’s PATH environment variable to access the above directory by simply writing a command in CLI without writing the entire path.

Search for “environment” in the search box. Click on Edit the system environment variables > Environment variables.
Searching for environment variables

After following the above steps, the Environment variables window will show up. Click on Path > Edit > New and paste C:\MinGW\bin. Click on Ok and you have successfully edited your PATH environment variable.
Downloading and setting up VS Code
As we have set up our compiler, now we’re all ready to download VSCode and write our first C/C++ program.

Click here to download VS Code. After downloading open the setup file.
Accept the agreement , check all the boxes shown in the picture, if you want you can also check the Create a desktop icon box and click on Next > Install . Congratulations, you have successfully installed VS Code on your machine.🎉
VS Code setup window

VS Code is all ready now to write our first code, but let’s download some important extensions to make our work even easier.

Head over to the Extensions tab (Ctrl+Shift+X), and search “c/c++” , click on the first extension you see i.e. C/C++ by Microsoft and then Install .
This extension adds language support for C/C++ to Visual Studio Code, including features such as IntelliSense and debugging.

Now we’ll download yet another extension. Search for “Code Runner Jun Han” , click on the first extension you see and install it.
This extension lets you run code snippets and code files for multiple languages like C, C++, Java, JS, PHP, Python, etc.

To run our code in the integrated terminal of VS Code, we need to do one last thing. Go to the Settings tab (Ctrl+,) search “ code runner terminal ” and check the same box as shown in the picture.

Congratulations, on following the article till the end, and successfully setting up the VSCode environment for C/C++ development.

ntechdevelopers

http://blog.ntechdevelopers.com/

Top comments (0)