Installing C/C++ Compiler for Programming on Windows

To write C/C++ code, you must first install the C/C++ compiler on your computer. This tutorial will show you how to install the C/C++ compiler on Windows.

Installing MinGW C/C++ compiler on Windows

For Windows, we will install MinGW. MinGW stands for Minimalist GNU for Windows. MinGW (previously mingw32) is a free and open source software development environment for creating Microsoft Windows applications. MinGW includes compilers for C, C++, as well as other related tools. Although MinGW produces 32-bit executables, they can be run on both 32-bit and 64-bit versions of Windows.

Follow the steps below to install MinGW C/C++ compiler on Windows:

  1. Download MinGW.
  2. After the download is complete, navigate to the location where you have downloaded the .exe file. Double click on the .exe installation file and follow the installation wizard until it is complete. Keep the installation directory default as shown in the image below:
  3. When you see MinGW Installation Manager window, mark all the packages for installation as shown in the image below:
  4. Go to installation menu and choose Apply Changes as shown below:
  5. On the next window, choose the Apply button and wait the installation to complete.
  6. Once the installation is complete, Go to the WinGW installation directory and copy the C:\WinGW\bin directory location of WinGW as shown below:
  7. Type env in the search and click on the Edit the system environment variables shortcut as shown in the image below:
  8. On the System Properties window, click Environment Variables button.
  9. Under System variables, select Path and click on the Edit button to set path for the WinGW. Next, click New button and enter the location of C:\MinGW\bin directory that you had copied previously as shown in the image below:
  10. Choose OK button.
  11. Open a command prompt and type g++ -v to verify the MinGW installation.
  12. Download and install Visual Studio Code IDE.
  13. Launch Visual Studio Code after the installation is complete.
  14. Go to Visual Studio Code Extensions and install C/C++ by Microsoft and Code Runner by Jun Han.