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?
It indicates it couldn't find
gcc.exe
.Maybe you haven't set the path correctly?
shows the path to gcc.exe? Otherwise, compilation is similar to Unix:
Where is your
gcc
?My
gcc
is in "C:\Program Files\CodeBlocks\MinGW\bin\".I am quite late answering this question (5 years to be exact) but I hope this helps someone.
I suspect that this error is because of the environment variables instead of GCC. When you set a new environment variable you need to open a new Command Prompt! This is the issue 90% of the time (when I first downloaded GCC I was stuck with this for 3 hours!) If this isn't the case, you probably haven't set the environment variables properly or you are in a folder with spaces in the name.
Once you have GCC working, it can be a hassle to compile and delete every time. If you don't want to install a full ide and already have python installed, try this github project: https://github.com/sophiadm/notepad-is-effort It is a small IDE written with tkinter in python. You can just copy the source code and save it as a .py file
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.
You can permanently include the directory of the MinGW file, by clicking on My Computer, Properties, Advanced system settings, Environment variables, then edit and paste your directory.
First:
Add your minGW's bin folder directory ( ex: C\mingw64\bin ) in System variables => Path. visual example
Compile:
.c: gcc filename.c -o desire
.cpp: g++ filename.cpp -o desire
Run:
desire/ or ./desire