2

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?

1

1 Answer 1

4

Edit:

Add the -mwindows flag when compiling.

3
  • Which argument there corresponds to argc and which to argv? Or how to map lpCmdLine to argc and argv? Sep 5, 2010 at 17:11
  • Updated answer with a much more simple solution.
    – user142162
    Sep 5, 2010 at 17:18
  • Thanks, I added -mwindows to the command line when I was linking (not compiling) the files, and now it works great
    – Frxstrem
    Sep 5, 2010 at 18:01

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.