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

Explanation:

This error message typically occurs when the g++ compiler is not installed on your system or its path is not set properly.

To resolve this issue, you can follow these steps:

  1. Check if g++ is installed on your system. Open your command prompt or terminal and run the following command:
  2. g++ --version

    If g++ is not installed, you need to install it. You can download and install the GNU Compiler Collection (which includes g++) from the official website: https://gcc.gnu.org/

  3. If g++ is already installed, make sure its installation directory is added to the system’s PATH environment variable.
    • For Windows:
    • Open the ‘Environment Variables’ settings on your system and add the directory path containing g++ to the ‘Path’ variable. For example: C:\MinGW\bin. Make sure to separate multiple paths with a semicolon (;).

    • For Mac/Linux:
    • Edit your shell configuration file (e.g., ~/.bashrc or ~/.bash_profile) and add the following line:

      export PATH="/usr/local/bin:$PATH"

      Replace /usr/local/bin with the actual directory path where g++ is installed.

After making these changes, restart your command prompt or terminal and try running the g++ command again. It should now be recognized as a valid command.

Example:

If you installed g++ in the directory C:\MinGW\bin, you would add the following path to the system’s PATH environment variable:

<div>
    <p>The command prompt PATH variable should look like this:</p>
    <p>C:\MinGW\bin;other\paths;...</p>
</div>

Read more interesting post

Leave a comment