GHC编译错误

Xod*_*rap 2 haskell ghc

我创建了一个非常简单的程序:

module CompileTest(main) where

main = putStrLn "Hello, World!"
Run Code Online (Sandbox Code Playgroud)

当我尝试使用以下方法编译它时ghc CompileTest.hs:

/usr/lib/ghc-6.12.1/libHSrtsmain.a(Main.o): In function `main':
(.text+0x10): undefined reference to `ZCMain_main_closure'
/usr/lib/ghc-6.12.1/libHSrtsmain.a(Main.o): In function `main':
(.text+0x18): undefined reference to `__stginit_ZCMain'
Run Code Online (Sandbox Code Playgroud)

有谁知道这是什么?我没有做任何复杂的事情.它在GHCi中运行良好.

Tho*_*son 5

main功能必须在Main模块中.那或使用-main-isGHC标志.此外,GHC <7时,您需要使用编译标志--make.