[Solved] gcc is not recognized as an internal or external command

GNU Compiler Collection (GCC) is a compiler used to compile C programs. For other languages than C, there are different compilers available which all go together as a one package. Such as for C++ you can use G++ compiler and for Fortran you can use GFortran compiler.

You are getting “gcc is not recognized as an internal or external command, operable program or batch file.” error that means you are trying to use gcc command to compile a C program using command line. This article will help you to fix the gcc command error when you compile a C program.

gcc is not recognized as an internal or external command, operable program or batch file

Here are the steps you need to follow to get rid of this error.

Step 1: Install gcc compiler

The first thing you need to check is whether you have installed the gcc compiler or not. If you have not installed gcc compiler and trying to use gcc command then the error message is obvious as the functionality is not available on your computer.

If you have not installed gcc compiler, then install MinGW gcc compiler on your development environment. Click below for a step-by-step guide to set up gcc compiler.

Install gcc Compiler on Windows 10

If you have already installed the gcc compiler, then follow the next step.

Step 2: Set PATH variables

If you have installed gcc compiler and still getting the error message, then the next troubleshooting step is to check the system PATH variable.

Either you have not entered gcc path in PATH system variable or the entered path is incorrect. Here are the steps on how to set the correct gcc path in the environment variable.

  • 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. It opens the environment variables window.
    set Environment Variables
  • In the Environment variable window under System variables select path variable and click on Edit. Make sure to set value in the System variable and not in the user variable.
    Set PATH variable in Windows
  • Add gcc compiler path upto bin folder in the variable value as shown below and click OK.
  • Close all windows and open new command prompt and compile your program. Now it will compile your program without any error.

Read also: 50 Important Turbo C++ Keyboard Shortcuts You Should Know

Here for reference, we have compiled and executed the following sample c program using gcc compiler

include

#include <stdio.h>
int main() {
printf("!!!Hello Friends!!!");
return 0;
}

Note: After setting the environment variable, make sure to use a new command prompt to execute the gcc command. If you tried to run the gcc command on the same command prompt then you will again get “gcc is not recognized as an internal or external command” error message.

That’s all it takes to fix the gcc error while compiling a C program. Do let us know if you are able to fix the error in the comments sections.

Cheers !!!

9 thoughts on “[Solved] gcc is not recognized as an internal or external command”

    1. After setting the environment variable, you need to run the program in a new command prompt. In the already opened command prompt, the changes you made will not propagate.

    2. make sure to install the path correctly inside the **path** of environmental variables, don’t paste outside of the path name

    1. You need to try running the command in a new command prompt/terminal after setting the PATH variable.

    1. Check if the PATH variable is set properly. If you have installed the compiler and PATH variable is set, there will not be any error.

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top
Scroll to Top