Categories: Command Line Errors

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.

  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.
  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.

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.

Srini

View Comments

  • 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

  • I can see MinGW in the path but it still says not recognized! I double checked my path and it is 100 % correct. What could the issue be?

    • Same problem. Have the path added to system level, user level and mingw copied to a directory path with no spaces in it (programfiles 86 has a space and sometimes spaces in paths are a problem).

  • I can see MinGW in the path but it still says not recognized! I double checked my path and it is 100 % correct. What could the issue be?

    • Maybe the mingw is installed in another drive or folder, so ,if you can add it in current folder, error may not be there. Hope it helps.

    • I had this problem too when I was looking through the mingw files I noticed theres nothing in the bin directiory. I looked in the other folders and found a bin folder with the correct contents it was called ucrt64\bin.

      For me it works now

  • sir, it worked. But still having problem while running c++ program. I guess there is different command for c++. Please help me.

Share
Published by
Srini

Recent Posts

Add new user account from command line (CMD)

Adding users from command line is much easier than going through the UI. It saves…

4 years ago

Delete directory from command line [Rmdir]

Do you want to delete a directory from Windows command prompt(CMD)? This post explains how…

4 years ago

TaskKill: Kill process from command line (CMD)

We can kill a process from GUI using Task manager. If you want to do…

4 years ago

Kill Chrome from command line

Chrome is definitely the stable browser compared to other ones and it has been my…

4 years ago

Find windows OS version from command line

Windows has multiple command line utilities that can help find the version of the Windows…

4 years ago

How to check if Windows 32 or 64 bit?

There are multiple ways to check whether a Windows computer is running 32-bit OS or…

7 years ago