Simple Steps to Install gcc compiler and g++ Compiler on Windows 10

If you are a developer and trying to compile your C/C++ program in the command prompt, then this article will help you to install gcc compiler and g++ compiler on your Windows 10 computer in order to compile your code. If these compilers are not installed, you will get the error “gcc is not recognized as an internal or external command“.

Before we proceed with the installation steps, you must know about these tools.

  • Minimalist GNU for Windows (MinGW): It is a development environment for Windows applications.
  • gcc compiler: Use this compiler to compile C programs.
  • g++ compiler: Use this compiler to compile C++ programs.

gcc and g++ compiler along with other compilers come together as a package when you install the MinGW tool. So, you are required to download and install the MinGW tool on your development environment.

Here is a step-by-step guide.

Step 1: Download MinGW tool

You can download the installable from MinGW official website or from any other trusted source.

On the official website, click on the Downloads tab on the top side and go to List of Releases. Under the Download List section, look for the Windows download button as shown below and download the setup file.

The mingw-get-setup.exe file gets downloaded to your computer in the downloads folder.

Step 2: Steps to install MinGW

  1. Right-click on the mingw-get-setup.exe file and run as administrator.
  2. In the MinGW Installation Manager Setup Tool window, click on Install.
  3. By default, the installation directory is set as C:\MinGW. You can change the installation directory by clicking on the Change button and selecting a different folder.
  4. Click on the Continue button to start the installation.
  5. Once the installation is complete, click the Continue button to close MinGW Installation Manager Setup Tool.

Step 3: Install packages in MinGW / Install gcc compiler

Once you install MinGW, open MinGW Installation Manager from the Windows start menu that contains the list of packages you can install.

MinGW Installation Manager to install packages

Select the packages you want to install and right-click and choose Mark for Installation. Make sure to mark all GNU C compilers as shown below.

Install GNU C Compiler packages in MinGW

Note: After installation, if you want to remove, upgrade or reinstall certain packages, then you can use MinGW Installation Manager and choose respective option by right-clicking on the package.

Once you mark all packages for installation click on Installation menu and select Apply Changes.

MinGW Install packages

In the Schedule of Pending Actions window, click on Apply button. It starts installing marked packages on your local environment.

Step 4: Set up the environment variable for MinGW

Once the MinGW setup is complete and the gcc and g++ compiler packages are installed, you must set the PATH variable for your computer.

  • Go to Control Panel → System and Security → System or right-click on This PC → Properties.
  • Click on Advanced system settings. It opens System Properties dialog box.
  • In the System Properties window, under the Advanced tab, click on the “Environment Variables...” button to open the environment variables window.
set Environment Variables in Windows
  • Under the System variables section, edit the path variable and append gcc compiler path up to the bin folder.

Note: The bin folder contains executable files of the compiler.

Set PATH variable in Windows

Step 5: Test installation of gcc and g++ compiler

To test if the gcc compiler or the g++ compiler is installed correctly, open a command prompt and type the following command.

For gcc compiler: gcc –v
For g++ compiler: g++ -v

gcc –v command

If these commands return the version of the compiler, then it means you have installed gcc and g++ compilers correctly.

If you are getting an error message “gcc is not recognized as an internal or external command” then click on the below link to resolve the error.

Fix: gcc is not recognized as an internal or external command, operable program or batch file.

Final words:

These are all the steps you need to follow in order to install gcc compiler and g++ compiler on your computer and execute your C/C++ program in the command prompt. If you have any questions or issues, do let us know in the comments section.

Cheers !!!

4 thoughts on “Simple Steps to Install gcc compiler and g++ Compiler on Windows 10”

  1. Thank you So Much!! This helps a whole lot. I am a new programmer and Visual studio and VS code were giving me problems compiling and running C++ programs. Through research, I found out that I needed to install a C++/g++ compiler on windows. The Best option for doing that was through MinGW. However, the project site for MinGW is defunct and only the source Forge file is available so I did not know what to do. Fortunately, this site had the answer to my problem and helped me to install the compilers and get back to work.

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top
Scroll to Top