How to get only the object file without main function by ghc?

[Source Code]

data FooBar = Foo | Bar

[Command]

$ ghc -c foo_bar.hs
foo_bar.hs:1:0: The function 'main' is not defined in module 'Main'

[Configuration]

Glasgow Haskell Compiler, Version 6.12.3, for Haskell 98, stage 2 booted by GHC version 6.10.4


You should define your type in a module, and then compile it:

module Test where
data FooBar = Foo | Bar

By invoking ghc -c foo_bar.hs , the object file foo_bar.o will be generated without having to define main .

链接地址: http://www.djcxy.com/p/43420.html

上一篇: 如何将Haskell编译为无类型lambda演算(或GHC核心)?

下一篇: 如何仅通过ghc获取没有main函数的目标文件?