![]() |
Logo Credits: Papirus Development Team |
Visual Studio Code or VS Code is an open-source code editor by Microsoft. It is a well know editor among developers. This blog is focused on helping you set up your VS Code to run any C or C++ program on it.
Things you will need
1. VS Code
2. MinGW Installation Manager Setup
So, the first thing that you will need is the VS Code itself. If you have already installed then you can move on to further steps but if you haven’t then you can download it by going to the official website.
After that, you will have to download and install MinGW for installing the GCC and G++ compilers which you will need for compiling your C and C++ programs.
Note: You will need an Internet Connection throughout the process so make necessary arrangements.
MinGW Installation
After downloading the MinGW setup, run it and you will see a screen like below
Click on install.
Next, you will have to set the installation drive. The default will be C Drive and I will suggest you keep the default. There will be other user options as well so leave them as they are and click on continue.
After the installation is completed, click on continue.
Once you click on continue, MinGW Installation Manager will open.
Now here make sure that you are in the Basic Setup section.
In the Basic Setup, the one package that you need is mingw32-gcc-g++
To install it we will have to make it for installation.
Just click on the package name and you will see the option for Mark for Installation.
Once it's done then it will be marked.
Now, go ahead and click on the Installation option in the menu of MinGW Installation Manager and then click on Apply Changes.
As you do that one pop-up will open and there you just have to click on apply to install the package that we marked in the previous step.
Now the packages will be downloaded.
Once its done you will see a successful message.
You have successfully installed GCC and G++ compilers on your system but we are not done yet. It won't work in VS Code. As you have just installed it and VS Code doesn’t know about it.
For making it work in VS Code, you just have to do one last step and that is to set the path for MinGW in the environment variable so that the VS Code knows where to find the required C and C++ compilers when they are needed.
So, now you will have to locate the MinGW folder which will be created in the C Drive as we selected that as our drive to install.
Here, go to the bin directory.
There you will find the gcc and g++ executable files so now copy the path for this bin folder i.e. C:\MinGW\bin
Now, open environment variables by going into system properties.
Now, under user variables select Path variable and click on Edit.
Now, click on New and paste the copied path for MinGW bin folder.
Click on OK and it's done.
You can check if it's working or not by opening the VS Code and run any C and C++ programs.
Note: Install Code Runner extension in VS Code for running programs.
thanks for the help :)
ReplyDeleteI read a article under the same title some time ago, but this articles quality is much, much better. How you do this.. henderson mortgage,
ReplyDelete