What command does one have to enter at the command line in Windows 7 to compile a basic C program?
Like I am literally wondering what you type in the command prompt, to compile a .c file.
I tried:
> gcc foo.c
But it says:
'gcc' is not recognized as an internal or external command, operable program or batch file.
I also tried:
> minGW foo.c
But I got back:
'minGW' is not recognized as an internal or external command, operable program or batch file.
I have a path environment variable set to where MinGW is installed:
C:\Program Files (x86)\CodeBlocks\MinGW\bin
I can't really find any information on where I'm going wrong, and can't find anything in the official MinGW documentation, as it seems like this is something so simple, sort of an embarrassing question, that it's figured people know what to do?
To avoid giving the complete path each time you want to compile a program, you can add the MinGW's bin directory to the path variable of FireCMD. To do this you can give this command: path -a. This will open Browse for Folder dialog box from where you will be able to select the directory.
It indicates it couldn't find gcc.exe
.
I have a path environment variable set to where MinGW is installed
Maybe you haven't set the path correctly?
echo %path%
shows the path to gcc.exe? Otherwise, compilation is similar to Unix:
gcc filename.c -o filename
I've had this problem and couldn't find why it kept happening. The reason is simple: Once you have set up the environment paths, you have to close the CMD window, and open it again for it be aware of new environment paths.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With