How do you suppress the console window on Windows?

ⅰ亾dé卋堺 提交于 2020-02-02 10:11:04

问题


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?


回答1:


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)



来源:https://stackoverflow.com/questions/58008692/how-do-you-suppress-the-console-window-on-windows

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!