tags:

views:

46

answers:

1

Hi.

I am compiling this program on Windows, with gcc (MinGW) and GTK+:

#include <gtk/gtk.h>

void *destroy(GtkWidget *widget, gpointer data)
{
    gtk_main_quit();
}

int main(int argc, char *argv[])
{
    // Initalize GTK+
    gtk_init(&argc, &argv);

    // Create GTK+ window
    GtkWidget *window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
    g_signal_connect(window, "destroy", G_CALLBACK(destroy), NULL);

    // Show all widgets
    gtk_widget_show_all(window);

    // Enter loop
    gtk_main();

    // Exit program
    return 0;
}

It compiles and runs, but the problem is that when I launch the program, it launches in a terminal window before opening the GUI window.

How do I prevent this from happening?

+3  A: 

Edit:

Add the -mwindows flag when compiling.

Tim Cooper
Which argument there corresponds to argc and which to argv? Or how to map lpCmdLine to argc and argv?
Jonathan Leffler
Updated answer with a much more simple solution.
Tim Cooper
Thanks, I added `-mwindows` to the command line when I was linking (not compiling) the files, and now it works great
Frxstrem