ali
ali

Reputation: 11045

Create a GUI application directly with GCC, remove console

I decided to create applications direct with Notepad + GCC Compiler (and the entire Mingw environment).

Well I started by creating a simple Win32 application (a simple window). The file is only 4 Kb (which, with an IDE like C:B or VS is about 8 kb.

Anyway, my problem is that the window is displayed but also a window console. Well, I don't want the console to appear but only the GUI window. I think this is achieved by creating manifest files or something like that, of which I don't know much about, as this is the first time I am trying this. How do I tell GCC that it shouldn't create a console window - just a GUI window?

Thanks!

Upvotes: 1

Views: 3460

Answers (3)

tiger zhang
tiger zhang

Reputation: 11

Yeah, -mwindows can solve the problem. And I found another option, passing -Wl,--subsystem,windows when using gcc to compile. Both of them are OK.

Upvotes: 1

ali
ali

Reputation: 11045

I found out how to do it. For anyone having the same question: use -mwindows in your command line, when compiling the code with GCC. Thanks!

Upvotes: 0

David Heffernan
David Heffernan

Reputation: 613461

You need to create an executable that targets the GUI subsystem rather than the console subsystem. In the MS tools the normal way to indicate that is to use a different form of main function:

int WINAPI WinMain(HINSTANCE hThisInstance, 
                   HINSTANCE hPrevInstance, 
                   LPSTR lpszArgument, 
                   int nCmdShow)

I believe that mingw supports the same convention.

Upvotes: 1

Related Questions