build: use -mwindows for gui targets when linking with mingw

Fixes #3499