Take the basic example Gtk+ app and calll it main.vala:
using Gtk;
int main (string[] args) {
    Gtk.init (ref args);
    var window = new Window ();
    window.title = "First GTK+ Program";
    window.border_width = 10;
    window.window_position = WindowPosition.CENTER;
    window.set_default_size (350, 70);
    window.destroy.connect (Gtk.main_quit);
    var button = new Button.with_label ("Click me!");
    button.clicked.connect (() => {
        button.label = "Thank you";
    });
    window.add (button);
    window.show_all ();
    Gtk.main ();
    return 0;
}
Add a simple meson.build file:
project('gui-test', 'vala', 'c')
dependencies = [
    dependency('glib-2.0'),
    dependency('gobject-2.0'),
    dependency('gtk+-3.0')
]
sources = files('main.vala')
executable('gui-test', sources, dependencies: dependencies)
With the toolchain from msys2 this can be compiled to a Windows application with the usual steps:
meson build
ninja -C build
The resulting executable will have the Windows console subsystem (-mconsole).
It opens a console window when launched from Windows explorer.

How do I avoid having a console window in this gui app?
Set gui_app: true in the executable:
project('gui-test', 'vala', 'c')
dependencies = [
    dependency('glib-2.0'),
    dependency('gobject-2.0'),
    dependency('gtk+-3.0')
]
sources = files('main.vala')
executable('gui-test', sources, dependencies: dependencies, gui_app: true)
This is documentend in the meson manual:
gui_app when set to true flags this target as a GUI application on platforms where this makes a difference (e.g. Windows)

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With