Sunday, July 26, 2009

Can't Compile C code into an?

I'm just starting to learn C. Last night, I downloaded MinGW to compile my programs (v5.1.3.exe installer) and installed it to C:\MinGW. Last night I could compile programs by changing to my programs directory with CHDIR and then running the GCC command with Command Prompt. Today, it doesn't recognize the command GCC (the command "gcc" is not recognized as an internal or external command, batch file...) unless I have navigated C:\MinGW\bin with Command Prompt and then run gcc. What gives?





Thanks alot!





ringchow2004

Can't Compile C code into an?
I do not what OS you are using. But find the enviorment variables tab or button. It can usually be found either from selecting System in the control panel or Properties by right clicking on My Computer. You need to set the Path variable to include the location of MinGW\bin. Look for Path, if it doesn't exist you will have to create it(else highlight Path and click Edit), and do not confuse it with classpath. There may be other stuff already on the line, DO NOT DELETE this; instead, scroll to the end of the line and add a ';' if it is not there. The ; separates different directories. After the ; type your path C:\MinGW\bin, and click ok you will have to restart any shell windows for this to take effect. Now you should be able to run gcc from any directory.





As an alternative, you can download Dev-C++, it uses the Mingw and is pretty nice IDE.
Reply:ya u have to be in the right directory then only the command would work you need to change dir to the right one then compile


No comments:

Post a Comment