bonjorno7
bonjorno7

Reputation: 51

G++ how to compile a program that doesn't open the console. It has to be multiplatform, not just for Windows.?

I'm running G++ (mingw tdm, I think) from the command line, and I'm trying to make a program that doesn't open the command prompt/terminal.

I know it's possible: in CodeBlocksI can just use the project's properties and set it to 'GUI Application', but I have no idea what flag to use with g++.

If I can't fix it I'll just go back to using CodeBlocks, but prefer like using NotePad++ with G++. If it somehow is not possible why and then how does Code::Blocks do it?

Upvotes: 2

Views: 2678

Answers (2)

Lisoph
Lisoph

Reputation: 25

-mwindows: This option is available for Cygwin and MinGW targets. It specifies that a GUI application is to be generated by instructing the linker to set the PE header subsystem type appropriately.

So yeah, this flag will only work on Windows.

After some programming I noticed that on Linux there is no standard I/O console at all. This means you will get console I/O only when you run your program via the console ( ./MyProgram ). Now that's convenient.

Upvotes: 0

Lisoph
Lisoph

Reputation: 11

Add "-mwindows" to your linker options. I'm not 100% sure if this works on other OS's than windows, you just gotta try it.

Upvotes: 1

Related Questions