2
我創建了一個非常簡單的程序:GHC編譯錯誤
module CompileTest(main) where
main = putStrLn "Hello, World!"
當我嘗試編譯使用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'
有誰知道這是什麼嗎?我沒有做任何複雜的事情。它在GHCi中工作正常。
作爲托馬斯'回答的補充,用'-main-is'標誌,'main'函數不需要叫'main',你可以使用'ghc --make -main-is Foo.bar Foo .hs'用模塊'Foo'中的函數'bar'作爲入口點進行編譯。 – 2012-03-10 16:35:53