Hello, Windows!

The Simplest Win32 Program You Will Ever See

Perhaps not, but the following code is probably the simplest Win32 program that it is possible to write. Follow the link to see the code.

simple.c

You can build that program using the following sequence of commands (assuming you have saved the code as a file called simple.c):

gcc -c -o simple.o simple.c
gcc -o simple.exe simple.o -mwindows

Did that give you any trouble? If so:

> gcc -c -o simple.o simple.c
> gcc -o simple.exe simple.o
simple.o(.text+0x2a):simple.c: undefined reference to `MessageBoxA@16'
gcc -c -o simple.o simple.c
gcc -o simple.exe simple.o -luser32 -Wl,--subsystem,windows

A More Complete Example

This is a longer and more complex example which creates a window with a button in it.

test.c

You can compile that program like this

gcc -c -o test.o test.c
gcc -o test.exe test.o -mwindows

the same way as simple.c above. If your compiler doesn't support -mwindows try this:

gcc -c -o test.o test.c
gcc -o test.exe test.o -luser32 -lgdi32 -Wl,--subsystem,windows