如何阻止使用 MinGW (g++) 编译的程序在 Windows 中打开控制台窗口
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/4441551/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to stop a program compiled with MinGW (g++) from opening a console window in windows
提问by leanid.chaika
I compiled a program using MinGW g++. When I run it, it opens a console window in addition to the main application window. What's the compiler flag to stop this?
我使用 MinGW g++ 编译了一个程序。当我运行它时,除了主应用程序窗口之外,它还会打开一个控制台窗口。阻止此操作的编译器标志是什么?
采纳答案by In silico
I believe the compiler switch for that is -Wl,-subsystem,windows
.
我相信编译器开关是-Wl,-subsystem,windows
.
The -Wl,<options>
switch passes <options>
to the linker. The -subsystem
switch tells the linker which system to target when generating the executable.
该-Wl,<options>
开关传递<options>
给链接器。该-subsystem
开关告诉链接器在生成可执行文件时要定位哪个系统。
回答by leanid.chaika
I just add -mwindows
to linker flags.
我只是添加-mwindows
到链接器标志。