- 1 year ago
Stop command prompt from opening when running exe file built from haskell project
When building an executable from a Haskell project, you can configure the build settings to prevent the command prompt window from opening when running the executable. This behavior is specific to the build tool or environment you are using for your Haskell project. Here are some approaches based on common build tools:
Stack:
If you are using Stack as your build tool, you can set the--no-ghc-package-path
flag when building the executable. This flag tells Stack to use thesystem-ghc
package instead of the package environment specified in your project. Thesystem-ghc
package runs the executable without opening a command prompt window. You can use the following command to build the executable:bashstack build --flag your-project:executable-name --no-ghc-package-path
Cabal:
If you are using Cabal as your build tool, you can modify the.cabal
file of your project to include theWin32GUI
flag. This flag tells Cabal to build the executable as a GUI application, which prevents the command prompt window from opening. In your.cabal
file, ensure that theexecutable
section has thebuild-type
set toCustom
and theghc-options
include the-optl-Win32GUI
option:cabalexecutable your-executable-name
build-type: Custom
main-is: Main.hs
ghc-options: -threaded -optl-Win32GUI
...
Then, build the executable using the
cabal build
command:bashcabal build
These are general approaches to prevent the command prompt window from opening when running an executable built from a Haskell project. The specific steps may vary depending on your project setup and build tools. Be sure to consult the documentation for your specific build tool for more detailed instructions.