阴谋集团:找不到可执行测试的'Main-Is'字段1



我想用cabal运行一个非常简单的"Hello World"项目。

这是我保存项目的文件夹(ubuntu)

mtt@mttPC:~/Documents/Haskell/test1$ ls
dist          Greetings.o  Setup.hs  test1.cabal

Main.hs包含:

module Greetings where
main :: IO ()
main = print "hello"

Hello world实际工作:

mtt@mttPC:~/Documents/Haskell/test1$ runhaskell Main.hs configure --ghc
"hello"

test1.cabal文件已经生成,cabal init:

-- Initial test1.cabal generated by cabal init.  For further documentation,
--  see http://haskell.org/cabal/users-guide/
name:                test1
version:             0.1.0.0
-- synopsis:            
-- description:         
-- license:             
license-file:        LICENSE
author:              mtt
maintainer:           
-- copyright:           
-- category:            
build-type:          Simple
cabal-version:       >=1.8
executable test1
  -- main-is: Main.hs     
  -- other-modules:     
  build-depends:       base ==4.6.*

我不明白为什么:

mtt@mttPC:~/Documents/Haskell/test1$ cabal configure
Resolving dependencies...
Configuring test1-0.1.0.0...
Error: No 'Main-Is' field found for executable test1

您忘记取消注释告诉GHC构建哪个模块作为主要入口点的文件

...
executable test1
  main-is: src/Main.hs -- Or whatever is appropriate
  build-depends: base==4.6.*

相关内容

  • 没有找到相关文章

最新更新