Hackernoon logoHow to Compile C/C++ Code in VS Code (Windows) by@sameerbairwa

How to Compile C/C++ Code in VS Code (Windows)

image
Sameer Bairwa Hacker Noon profile picture

Sameer Bairwa

Love to write, Software developer, freelancer, machine learning Follow on Twitter

Compile your C/C++ code in Windows using Visual Studio code

So in this article, I’ll show you how you can compile your C/C++ code in Windows. To compile C/C++ code we need GCC/G++ to compile the code but Windows doesn't have a terminal like the Linux terminal or Mac terminal.

So instead, to compile your code in Windows VS Code, we need an extension called the C/C++ Compile Run extension.

To install it, you need to open your VS Code and goto extensions (shown in the below image ) and search for C/C++ Compile Run by danielpinto8zz6, install it.

image

Your 1 step is completed, now you need to install MinGW.

It is a free and open-source software development environment to create Microsoft Windows applications.

Go to its official site in the navigation section download.

image

Click on download and it will redirect you to the download page and click on

The windows icon like shown in the below image after the download installs it.

image

After successfully installation open MinGW Installation Manager.

image

It will look like the image. Click on "basic setup" and click on "all packages". Then, go to installation and click on "apply changes", it will take some after successfully applied.

You need to do one more thing to setup the environment.

image

Open your System Properties and click on Environment Variables.

image

Now select on System variables Path and click on edit.

image

Now click on new and go to Browse and in C drive find the MinGW folder and select bin folder.

image

That’s it - your environment has been setup.

Now you can compile your C/C++ code in your VS Code by pressing f6 on your keyboard.

That’s all about the code compilation in Windows. If you have any kind of doubt you can ask me or you can see my video.

I hope this helps you if you have any query feel free to ask.

Previously published at https://laptrinhx.com/how-to-compile-c-c-code-in-vs-code-windows-2735242511/

https://www.subpals.com/?ref=8046

Tags

Join Hacker Noon

Create your free account to unlock your custom reading experience.