Search notes:

gcc -mconsole

The mconsole flag is used to create a console subystem Windows executable.

See also

GCC options specifically for Cygwin and MinGW.
Other -m options

Index