简体   繁体   English

GHC编译错误

[英]GHC Compile Errors

I created a very simple program: 我创建了一个非常简单的程序:

module CompileTest(main) where

main = putStrLn "Hello, World!"

When I try to compile it using ghc CompileTest.hs I get: 当我尝试使用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'

Does anyone know what this is? 有人知道这是什么吗? I'm not doing anything complicated. 我没有做任何复杂的事情。 And it works fine in GHCi. 并且它在GHCi中工作正常。

The main function must be in the Main module. main功能必须在Main模块中。 That or use the -main-is GHC flag. 或使用-main-is GHC标志。 Also, with GHC < 7 you need to use the compilation flag of --make . 另外,对于GHC <7,您需要使用--make的编译标志。

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

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