≡ Menu

GCC is not recognized as internal or external command

If you have installed MinGW tools on your system and are trying to run gcc from command prompt, you might get this error – 'gcc' is not recognized as an internal or external command. This post explains how we can fix this problem once for all.

GCC not recognized on windows

  1. The first step is to check what all you have in your PATH environment variable. Run set path and verify this.
    c:\>set path
    Path=C:\Program Files (x86)\Windows Resource Kits\Tools\;C:\WINDOWS\system32;C:\Program Files\Intel\WiFi\bin\;C:\Program Files\Common Files\Intel\WirelessCommon\;c:\Program Files\Java\jdk1.7.0_79\bin;C:\Program Files (x8
    6)\Skype\Phone\;C:\Program Files (x86)\Quarantine\;C:\ProgramData\Oracle\Java\javapath;C:\Program Files (x86)\Windows Resource Kits\Tools\;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\
    Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0\;C:\WINDOWS\System32\WindowsPowerShell\v1.0\;C:\Program Files\Intel\WiFi\bin\;C:\Program Files\Common Files\Intel\WirelessCommon\;c:\Program F
    iles\Java\jdk1.7.0_79\bin;C:\Program Files (x86)\Skype\Phone\;C:\Program Files (x86)\Quarantine\;c:\Program Files (x86)\Mozilla Firefox"

    If you have such a long path like in my case, use findstr to quickly check if it has mingw anywhere in the string.

    c:\>set path | findstr /I /C:"mingw"
    c:\>
  2. Now this tells me that I have not added MinGW installation folder yet to my path. I would need to add it then. The next step explains how to do this.
  3. The path values for system or any user can be edited in GUI. There are multiple ways to open the window where you can edit it. What I usually do is press the windows button and start typing ‘environment..’ which searches all files/programs with this name. You would see couple of links in the search results as shown below.
    Search results fir environment in start button
  4. Select ‘Edit system environment variables’. Both of them take you to the same window, but the system one allows you to edit system variables.
  5. In system variables, find the ‘PATH’ environment variable and then edit it to add MinGW path. You need to add ‘;’ at the end of the existing value and then enter MinGW path.Adding MinGW to PATH environment variable

After doing the above steps, open a new command prompt and run gcc to compile a C program.

c:\>type helloWindows.c
#include 
int main() {
        printf("Hello Windows");
}
c:>
c:\>gcc -o HelloWindows.exe helloWindows.c
c:\> HelloWindows.exe
Hello Windows

That completes the setup. Before I end the post, reiterating couple of important points.
1. Add path to system environment variable, not user environment variable.
2. Open a new command window after setting PATH.

Let us know if this post helped you to fix the problem. If you still have issues, please add to the comments the error you are getting into. We would do our best to reply and help you fix the problem.

4 comments… add one
  • Graham Ansell

    Good Stuff here, could be useful for future reference, thanks for posting

  • udit

    plz help me to how can i play a .mp3 file from turbo c compiler when i execute it in turbo c
    .also i know about sound function but that function works on some frequency range ..but i want the song should get imported and is played when i press CTRL+f9.
    And i have also used System calls to do this but not suceeding.
    my system configuration is:-
    32- bit operating system

  • Neha

    Thank you so much for this post. Helped a lot. Especially the last two points.

  • Emirali caferzade

    Thank you very much for this post. It solved my problem.
    Emirali

Leave a Comment