[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

First thing you need to check is whether you have installed 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 setup gcc compiler.

Install gcc Compiler on Windows 10

If you have already installed 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 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 following sample c program using gcc compiler

#include <stdio.h>
       printf("\n Hello Friends \n");
       return 0;

Note: After setting the environment variable, make sure to use new command prompt to execute gcc command. If you tried to run 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 !!!

Leave a Comment

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

Scroll to Top