views:

66

answers:

2

I'm following the tutorial:

http://zetcode.com/tutorials/gtktutorial/firstprograms/

It works but each time I double click on the executable,there is a console which I don't want it there.

How do I get rid of that console?

Platform: windows XP.

BTW I also have this trouble when right click on the icon:

GLib-WARNING **: g_main_context_check() called recursively from within a source's check() or prepare() member.

Is there anyone familiar with this?

+1  A: 

When you link, use the argument -mwindows

gcc -o simple simple.c `pkg-config --libs --cflags gtk+-2.0` -mwindows
Matthew Talbert
Thanks!Let me try if it works. What about the `GLib-WARNING` issue?
Gtker
Seems it's not working for windows. Though I've installed gcc environment already.
Gtker
No idea about that; as it's a warning, I'd probably just ignore it.
Matthew Talbert
What isn't working?
Matthew Talbert
But there will be thousands of the same warning as long as I don't cancel right click on the icon.
Gtker
It reports: `gcc: `pkg-config: No such file or directory`,`gcc: gtk+-2.0`: No such file or directory`
Gtker
I was just copying from the tutorial you linked. Presumably you've successfully compiled it before? Just do what you already did and add the "-mwindows"
Matthew Talbert
I'm using cmake to build, and it can't recognize the -mwindows switch: `set(CMAKE_CXX_FLAGS "-Wall -mwindows")`
Gtker
It wouldn't be CMAKE_CXX_FLAGS. I don't know CMAKE, but it would possibly be something like CMAKE_LXX_FLAGS (Look for "L")
Matthew Talbert
A: 

The console opens then an application outputs text (which perhaps was obvious). By default the application outputs text then an error occurs. Use g_set_printerr_handler() change that behaviour (into displaying an error dialog, writing to a file or whatever you want).

Grim
That's not the problem; on Windows, gcc builds console binaries by default, which open a console whether text is output or not. You have to link with the `-mwindows` switch to get a binary that doesn't open a console, as in @Matthew Talbert's answer.
ptomato