A Beginner’s Guide to Install gcc and g++ Compiler on Windows 10

If you are a developer and trying to compile your C/C++ program in 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 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 comes together as a package when you install MinGW tool. So, you are required to download and install 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 Downloads tab on the top right corner. 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 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 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 Compiler 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 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 System Properties window, under Advanced tab, click on “Environment Variables…” button to open environment variables window.
set Environment Variables in Windows
  • Under System variables section, edit the path variable and append gcc compiler path up to 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 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 command prompt. If you have any questions or issues, do let us know in the comments section.

Cheers !!!

3 thoughts on “A Beginner’s Guide to Install gcc 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