使用 MinGW 和 Eclipse 编译 Win32 GUI 应用程序(没有控制台)

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/7474504/
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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-19 17:00:51  来源:igfitidea点击:

Compiling a Win32 GUI app (without a console) using MinGW and Eclipse

c++eclipsegccmingw

提问by viraj

I'm using the eclipse IDE with MinGW as my compiler, to make a Win32 GUI app.

我使用 Eclipse IDE 和 MinGW 作为我的编译器,来制作一个 Win32 GUI 应用程序。

I want to get rid of the console, but compiling the program with -mwindowsoption has no effect and the console is still there.

我想摆脱控制台,但是使用-mwindows选项编译程序没有任何效果,控制台仍然存在。

Using the -Wl,--subsystem,windowsflag also produces no effect. What am I doing wrong ?

使用-Wl,--subsystem,windows标志也不会产生任何效果。我究竟做错了什么 ?

回答by Andrejs Cainikovs

For gcc on Windows, two things should be considered to build a non-console Windows app:

对于 Windows 上的 gcc,构建非控制台 Windows 应用程序应考虑两件事:

  1. Compiler option -mwindows
  2. Have WinMain()
  1. 编译器选项 -mwindows
  2. WinMain()

It is possible, however, to manually specify -Wl,-subsystem,windowsto the linker and include gdi32and comdlg32into the build. This is exactly what -mwindowsautomates.

这是可能的,但是,手动指定-Wl,-subsystem,windows给连接器,包括gdi32comdlg32到构建。这正是-mwindows自动化的原因。

Reference.

参考