‘g++’ is not recognized as an internal or external command, operable program or batch file.

            'g++' is not recognized as an internal or external command, operable program or batch file.
        

This error message usually occurs when the ‘g++’ compiler is not properly installed or its executable path is not set in the system’s environment variables.

To resolve this issue, you can follow the steps below:

  1. Check if ‘g++’ is installed:

    Open a command prompt and type ‘g++’ without quotes. If you see a message like “‘g++’ is not recognized as an internal or external command, operable program or batch file”, then ‘g++’ is not installed. Proceed to the next step.

  2. Install ‘g++’:

    ‘g++’ is part of the GNU Compiler Collection (GCC), which can be downloaded and installed from the official GCC website (https://gcc.gnu.org/). Choose the appropriate version for your operating system and follow the installation instructions.

  3. Set the executable path:

    After installing ‘g++’, you need to set its executable path in the system’s environment variables. Here’s how to do it in Windows:

    • Open the Windows Control Panel and go to System > Advanced system settings.
    • In the System Properties window, click on the “Environment Variables” button.
    • In the “System Variables” section, scroll down and find the “Path” variable. Select it and click on the “Edit” button.
    • In the “Edit Environment Variable” window, click on the “New” button and add the path to the ‘g++’ executable. The exact path may vary depending on your installation, but it is typically something like “C:\MinGW\bin” or “C:\Dev-Cpp\MinGW64\bin”.
    • Click “OK” in all open windows to save the changes and close the windows.
  4. Test ‘g++’ again:

    Open a new command prompt and type ‘g++’ without quotes. If you see a message showing the version and options of ‘g++’, then it is installed and set up correctly. You can now use ‘g++’ to compile your C++ programs from the command line.

Example:

Let’s say you have installed ‘g++’ in the directory “C:\MinGW\bin” and it contains the ‘g++’ executable. After setting the executable path in the system’s environment variables as described above, you should be able to run ‘g++’ from any command prompt without encountering the error message.

Related Post

Leave a comment