简体   繁体   English

如何使用ghc编译GUI可执行文件?

[英]How can I compile a GUI executable with ghc?

I ported a little Haskell program I wrote from Mac to Windows. 我将从Mac编写的Haskell小程序移植到Windows。 It's a GUI application (wxHaskell, compiled with ghc 6.12.1), so it does not need the command prompt window to open. 它是一个GUI应用程序(wxHaskell,使用ghc 6.12.1编译),因此不需要打开命令提示符窗口。 It does so, anyway, so my question: What must I do so that the program starts without opening a prompt window first? 无论如何,它确实是这样做的,所以我的问题是:我该怎么做才能使程序在没有首先打开提示窗口的情况下启动? Is there some ghc switch for this? 为此有一些ghc开关吗?

When using wxWidgets with cygwin, you can avoid having a console window appear by passing the -mwindows flag to the linker . 将wxWidgets与cygwin一起使用时,可以通过将-mwindows标志传递给链接器来避免出现控制台窗口。 You can tell GHC to pass flags to the linker using the -optl prefix , so you could try building with -optl-mwindows and see if that works. 您可以告诉GHC 使用-optl前缀将标志传递给链接器 ,因此您可以尝试使用-optl-mwindows ,看看是否-optl-mwindows

I've done that before when building a Haskell SDL application on Windows, and it worked for me. 在Windows上构建Haskell SDL应用程序之前,我已经做到了这一点,并且对我有用。 I think the -mwindows flag is cygwin-specific though, and I'm not sure what your install of GHC might be using as a linker. 我认为-mwindows标志虽然是cygwin特有的,但我不确定您安装的GHC可能用作链接器。

I don't have access to GHC on Windows, but it looks like you need to tell linker to use "windows" subsystem. 我没有在Windows上访问GHC的权限,但看来您需要告诉链接器使用“ Windows”子系统。 ghc -optl-mwindows ... may work. ghc -optl-mwindows ...可能有效。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM