Last updated: Apr 4, 2024
Reading time·5 min

The error "'gcc' is not recognized as an internal or external command, operable program or batch file" occurs for 2 main reasons:

Depending on if you run the gcc command in CMD or PowerShell, you will get one
of the following two errors:
The GNU Compiler Collection includes front ends for C, C++, Objective-C, Fortran, Ada, Go, and D.
First, make sure that you have gcc installed:
Once you click on the link, wait a few seconds and the download will start automatically.
Start the mingw-get-setup.exe file.
If you get shown a screen that "The app you're trying to install isn't a Microsoft verified app", click on Install anyway to proceed.


The default installation directory should be C:\MinGW as shown in the
screenshot.

If you already have MinGW installed, you will get a notification as shown in the screenshot.
If you do, click on Run now instead.

The next step is to add the path to the MinGW binary to your PATH environment variable:



Add the following path: C:\MinGW\bin.
C:\MinGW\bin

If you changed the path during the MinGW installation process, make sure to specify the correct path to the MinGW binary.
If you open the C:\MinGW\bin directory, you will see that it contains the GCC
executable file (gcc.exe).

This is the file that is run when you issue gcc commands from your terminal.
When you add the PATH to the MinGW bin folder to your PATH environment
variable, your terminal is able to find the gcc.exe file.
Click on OK 3 times to apply the changes.
Close all terminal sessions for the changes to be applied.
PATH environment variable to get updated.In a new CMD session, issue the gcc --version or gcc -v command to verify
that the error has been resolved.
gcc --version # Or the following gcc -v

As shown in the screenshot the gcc command is now available.
Once you've added the path to the MinGW bin folder to your System PATH
environment variable the issue should be resolved.
If the error persists, try to issue the following command in CMD.
set Path=C:\MinGW\bin;%PATH%

The command adds the path to the MinGW bin folder to your PATH environment
variable.
Try to issue the gcc -version command.
gcc --version # or gcc -v

You should also be able to run gcc commands by specifying the complete path
\mingw\bin\gcc.
\mingw\bin\gcc --version # or \mingw\bin\gcc -v
If the error persists, verify that your MinGW installation is located in
C:\.
If MinGW is installed in a different folder, you have to make sure to correct
the path to the MinGW\bin folder.
If the error persists, install MinGW using Chocolatey.
If you already have Chocolatey installed:
Click on the Search bar and type PowerShell.
Right-click on the PowerShell application and click "Run as administrator".

choco install mingw -y

To install Chocolatey:

Set-ExecutionPolicy Bypass -Scope Process -Force; [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072; iex ((New-Object System.Net.WebClient).DownloadString('https://community.chocolatey.org/install.ps1'))

choco to make sure Chocolatey is installed.
Now that you have Chocolatey installed, run the following command to install
mingw.
choco install mingw -y
Note that your shell should still be run using elevated permissions.

Close your active Command Prompt sessions and start a new session.
Try to issue the gcc -version command.
gcc --version # Or the following gcc -v

Chocolatey will automatically add the path to the MinGW bin folder to your
PATH after you install MinGW.
To solve the error "'gcc' is not recognized as an internal or external command, operable program or batch file", make sure:
bin folder to your system's PATH
environment variable.You can learn more about the related topics by checking out the following tutorials: