How can I compile C files into an executable (.exe) file?

c, exe, executable, makefile

Solution

There are several ways to compile c-files. Makefiles are just one possibility. But as you proposed it... Here are two tutorials for Makefiles:

- http://makepp.sourceforge.net/1.19/makepp_tutorial.html

- http://mrbook.org/tutorials/make/ (Content from 2012 accessable via waybackmachine)

But note, that you will also need a compiler (installed under cygwin).

Another possibility is to use Dev-C++, a IDE (Integrated Developement Environment) for C++. Once installed you can create a project and add your source code, and just compile the project. It also contains a c++ compiler (also supports C), which is named mingw. The makefile needed is automatically generated. So that's simpler for beginners.

You can download Dev-Cpp here: http://www.bloodshed.net/devcpp.html

Note: As you spoke about cygwin I assume you use Windows. Dev++ works only under windows, and you wont need cygwin.

Problem

I am unsure about compiling C files into executables by using Cygwin under Windows 7. Can anyone please tell me how to do this? I've read some tutorials but still don't get it. I understand that I need a Makefile, but what shall I write into it to have an executable file after the compilation process?

Original source