Here's an example. The following is a code sample for a simple Windows program. Cut and paste it into a file named hello.c to try it out.
int WINAPI WinMain (HINSTANCE hInstance,
MessageBox (NULL, "Hello", "Hello Demo", MB_OK);
If you want to create a Windows executable hello.exe, from a c file called hello.c, try the following:
This compiles hello.c into an object file, hello.o
gcc -o hello hello.o -mwindows
This creates an executable hello.exe from hello.o The -mwindows switch is needed to create Windows executables instead of console applications. It assures the appropriate Windows libraries are linked in for you. To get a console screen along with a standard windows application, add the -mconsole flag as well as -mwindows.
If you have resources from a resource file (.rc) that also need to be added to your executable, you'll need to compile the resource file as well as your other source files and include the compiled resources when linking to create the executable. Here's an example that shows how to compile and link in a resource file named resfile.rc.
windres -o resfile.o resfile.rc
gcc -o hello hello.o resfile.o -mwindows