How to Install VS Code and MinGW compiler for C C++ in WINDOWS

Here we are going to learn how to install VS Code and MinGW compiler for c c++ in windows. VS Code or Visual Studio Code by Microsoft is a code editor redefined and optimized for building and debugging modern web applications and cloud application. It is an IDE(Integrated Development Environment) in which we will write our programs. It supports many languages viz. C, C++, Python, Java, C# etc. We can also do web development in it as it also supports HTML, CSS, JavaScript, TypeScript, Node Js, Php, JSON etc. We will download the vs code from the official website of vs code. We will discuss about the process of downloading and setting up vs code in details below.

MinGW - W64 compiler compiles the code and simply translate it into machine readable language. We will install MinGW via MSYS2 which provides updated builds of GCC, MinGW - W64, and other helpful libraries and tools. You can download Mingw - w64 via MSYS2 from the official VS Code Website or just Visit MSYS2 Website here or you can also directly download the installer right here, you can choose any option to download the mingw - w64 installer everything's same. Lets start our step by step guide on how to install and setup vs code and mingw - w64 compiler for c c++ in windows.

How to Install VS Code and MinGW compiler for C/Cpp in WINDOWS

First visit the vs code official website . The website looks like this -

vs code website


Click on the dropdown arrow right beside Download for Windows Button and the click on other download. 

vs code dwonload

Or you can directly visit the download page from here 

vs code dwonload


Now download the installer according to your system. We will install the user installer x64 for windows. Once downloaded. Navigate to the folder where you have downloaded the installer, by default it gets download in your desktop downloads section.

Click on the installer to get started.

vs code install step 1

Click on I accept the agreement and the click on Next. 

vs code install step 2

Here you can browse the drive or folder to manually install vs code at your desired location. It is recommended not to alter anything here let vs code install at the location chosen by default. Simply click on Next.

vs code install step 3



Again Click on Next.

vs code install step 4

Here check all the boxes for Create desktop icon, Add "Open with Code" action to windows explorer file context menu, and 
Add "Open with Code" action to windows explorer directory context menu. 

vs code install step 5

Once checked everything, click on Next.

vs code install step 6

Now Click on Install.

vs code install step 7

And now uncheck launch vs code if you don't want to open vs code right now and click on Finish. Congratulations we have successfully installed VS Code in our system. Now its time for Mingw - w64 compiler.

If you have already installed mingw-gw64 as I mentioned at the beginning then that's great. If not then now its time to do. You can download Mingw - w64 via MSYS2 from the official VS Code Website or just Visit MSYS2 Website here or you can also directly download the installer right here, you can choose any option to download the mingw - w64 installer everything's same. Once downloaded. Navigate to the folder where you have downloaded the installer, by default it gets download in your desktop downloads section.

Click on the installer to get started. Then you just have to click next all the way till it gets installed. See the steps below

mingw-w64 install guide


mingw-w64 install guide


mingw-w64 install guide


mingw-w64 install guide


mingw-w64 install guide

Now click on Finish keeping the MSYS2 checked. This windows will appear. Now you need to copy paste somethings and don't forget to keep your pc connected to Wi-Fi as some important files will download automatically.

mingw-w64 install guide

Copy this and paste there (don't worry it is also available on msys2 website you can go there scroll to point 6 and copy paste from there)


copy paste this and press enter

pacman -S mingw-w64-ucrt-x86_64-gcc


mingw-w64 install guide

Now enter y in front of proceed with installation?

mingw-w64 install guide

Now write gcc --version to check the version of gcc just installed. It will also indicate that everything's installed correctly.

mingw-w64 install guide

Now copy paste this there (it is also available on vs code website you can go there scroll down to point 5 and copy paste from there)

copy paste and press enter

pacman -S --needed base-devel mingw-w64-x86_64-toolchain



mingw-w64 install guide

That's it. We have successfully installed mingw - w64 on our system. Now its time to set the path in environment variables.

Go to C drive >> msys64 >> mingw64 >> bin , and copy the path

path


Then close everything and on home screen right click on This Pc and then click on properties

environment variables path

Click on Advanced System Settings

environment variables path

Click on Environment Variables


environment variables path

Click on Path and then Edit

environment variables path


Now click on New and paste the copied path ctrl + v

environment variables path

Now close the tabs by clicking OK. Three tabs are open and you should close them by clicking OK only.

That's it we are all set now. Its time to open and setup VS Code now. We need to install some important extensions for c and c++. Open VS Code and in extension section search C/C++, click on first result and install it. 

vs code setup

Then search code runner and install it.

vs code setup

 Now its time to change some settings. Go to settings 

vs code setup

search code runner there and check run in terminal option.

vs code setup

So its all done now we have successfully installed and setup VS Code and MinGW compiler for c and c++. You can also take the help of tutorial if you are facing any problem in installation and setup. Language of tutorial is Hindi.



Post a Comment

If you have any doubts, please let me know

Previous Post Next Post