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.
- 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:\>
- 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.
- 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.
- Select ‘Edit system environment variables’. Both of them take you to the same window, but the system one allows you to edit system variables.
- 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.
Good Stuff here, could be useful for future reference, thanks for posting
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
Thank you so much for this post. Helped a lot. Especially the last two points.
Thank you very much for this post. It solved my problem.
Emirali
I can not edit system variables. I can’t select the button edit.
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).
same problem
This fixed it right up make sure not to mix up user and enviornment variables.
I’m getting gcc no such file or directory. why?
I get the same output, let me know if you figure out why, thanks, and all the best
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.
sir, it worked. But still having problem while running c++ program. I guess there is different command for c++. Please help me.
thank you so much! it worked. i wasted all night to fix this problem
Thanks, it helped me :D
It shows when mingw folder’s bin path is not added in the compilers action.
So , execute, set path= ; %MinGW bin path%;
Hope it helps !
I added to the Path of environment variable the mingw file with the correct location but stil gives me
‘gcc’ is not recognized as an internal or external command,
operable program or batch file.
Still not working, my Path has been created and still
gcc: error: missing filename after ‘-o’
gcc: fatal error: no input files
compilation terminated.
I was wondering if any steps existed to help with a similar error, but I am trying to use the “g++” command prompt. I tried to do these steps, but was not sure if I did it right or if it would even work for “g++.”
i have seen everything and done all the setting as per instructions , but is now also showing gcc is not recognised………..
Thank You so much. Last 2 points helped me a lot.
The string was not found even though I did what you instructed the error program that reads after set path | findstr
FINDSTR: Cannot open /
FINDSTR: Cannot open C:
I am running windows 10 64 bit. I have download MingW and edit the Path in system variables and still not able to compile my c program.
shows gcc is not recognised
Worked perfectly – very helpful – thank you
There was long text in my path…so i already set the path as c:\MinGw.after i am doing this also i open cmd and type hellowindows…after i press enter button it showed me the above error…why is that…and when i type only c:\.it showed me the syntax of the command is incorrect
it doesn’t work even after I add the system environment variable. When I try to run findstr it says FINDSTR // ignored
Tried this and set path variables. No Change. gcc still not recognised.
It still says that “The system cannot find the file specified.” -just after typing the first line of the Hello Windows program and pressing enter :(
Thank you! I had Minwn installed on my D drive and needed to move it to my C drive. Not sure why that doesn’t work.. but this article really helped.
hello, I have installed MinGW before and it was working but now I am trying to download it, it says file downloaded incorrectly. I have tried every solution but still not working. what should I do ?
Thank’s, that post really was helpfull o me. Worked perfectly!