Solving 'g++ is Not Recognized as an Internal or External Command' Error: Step-by-Step Guide

In this guide, we will walk you through the process of solving the 'g++ is not recognized as an internal or external command' error that you might encounter while working with the GNU Compiler Collection (GCC) on Windows. This error occurs when the system fails to find the g++ executable, which is essential for compiling C++ code.

Table of Contents:

Step 1: Install MinGW

MinGW (Minimalist GNU for Windows) is a popular software distribution that provides a collection of open-source development tools, including the g++ compiler, for Windows. To install MinGW, follow these steps:

Visit the MinGW official website and download the MinGW installer.

Run the installer and choose the installation directory (by default, C:\MinGW).

In the MinGW Installation Manager, select the following packages:

  • mingw32-base
  • mingw32-gcc-g++
  • msys-base

Click Apply Changes and wait for the installation to complete.

Once the installation is complete, you should find the g++ executable in the C:\MinGW\bin directory.

Back to top ↑

Step 2: Set Environment Variables

To ensure that Windows recognizes the g++ command, you must add the MinGW bin directory to the system's PATH environment variable. Follow these steps to update the PATH variable:

Open the System Properties window by right-clicking on My Computer or This PC and selecting Properties.

Click on Advanced system settings.

In the System Properties window, click on the Environment Variables button.

In the Environment Variables window, find the Path variable under the System variables section and click on Edit.

Add the path to the MinGW bin directory (by default, C:\MinGW\bin) at the end of the Variable value field, separated by a semicolon (;).

Click OK to save the changes and close all open windows.

Back to top ↑

Step 3: Verify Installation

To verify that the g++ command is now recognized by your system, follow these steps:

Open a new Command Prompt window (press Win + R, type cmd, and hit Enter).

Type the following command and press Enter:

g++ --version

If the installation was successful, you should see the version number of the g++ compiler.

Back to top ↑


1. Can I use a different compiler instead of MinGW?

Yes, you can use alternative compilers like Cygwin or Microsoft Visual C++ to compile C++ code on Windows.

2. How do I uninstall MinGW?

To uninstall MinGW, simply delete the MinGW installation directory (by default, C:\MinGW) and remove the MinGW bin directory from the Path environment variable.

3. Can I install MinGW on a different drive or directory?

Yes, you can choose a different installation directory during the MinGW installation process. However, make sure to update the Path environment variable accordingly.

4. How do I update the g++ compiler to the latest version?

To update the g++ compiler, open the MinGW Installation Manager, select the mingw32-gcc-g++ package, and click on Update.

5. What other programming languages does MinGW support?

Apart from C++, MinGW provides compilers for other popular languages like C, Objective-C, Fortran, Ada, and others.

Back to top ↑

Great! You’ve successfully signed up.

Welcome back! You've successfully signed in.

You've successfully subscribed to

Success! Check your email for magic link to sign-in.

Success! Your billing info has been updated.

Your billing was not updated.