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
make as usual... Just make sure you have it in your path and correct Makefile
In Windows 10, similar steps can be followed in other versions of windows.
Right Click on "My Computer" select Properties, Goto Advanced System Settings -> Advanced -> Select "Environment Variables.." .
Find "Path" select it and choose edit option -> Click on New and add "C:\MinGW\bin" (or the location of gcc.exe, if you have installed at some other location) -> Save and restart command prompt. Gcc should work.
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.
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
Instead of setting the %PATH%
you may enter your msys shell. In standard msys and mingw installation gcc is in path, so you can run gcc
or which gcc
.
I have a batch file sh.bat
on my Windows 7, in %PATH%:
C:\lang\msys\bin\sh.exe --login %*
Whenever I want to use gcc I enter cmd, then sh
, then gcc
. I find it very convenient.
When working with linux originated software avoid spaced directories like Program Files
. Install them rather to Program_Files
. The same regards to tools that you may want to run from msys environment.
I once had this kind of problem installing MinGW to work in Windows, even after I added the right System PATH in my Environment Variables.
After days of misery, I finally stumbled on a thread that recommended uninstalling the original MinGW compiler and deleting the C:\MinGW
folder and installing TDM-GCC MinGW compiler which can be found here.
You have options of choosing a 64/32-bit installer from the download page, and it creates the environment path variables for you too.