How to compile .hc files with gcc?

Duncan Coutts duncan.coutts at
Tue Jul 3 08:28:07 EDT 2007

On Tue, 2007-07-03 at 12:36 +0200, Srđan Stipić wrote:
> I wanted to compile simple Haskell program (simple.hs) to .c and after
> that to target platform (x86).
> I did  the following things:
> ghc -C simple.hs
> mv simple.hc simple.c
> gcc -c simple.c -I/usr/lib/ghc-6.6/include/
> And I got the following error message:
> How to compile .hc files with gcc?

One way to find out is to ask ghc how it does it! :-)

ghc -fvia-C -v -c simple.hs

this will produce lots of output including the gcc command that ghc uses
to compile the C code and then assemble it to a .o file.

It's probably best however, just to use ghc to compile your .hs files
to .o files, and especially to do the final link, since it does need
quite a large set of gcc flags.


More information about the Glasgow-haskell-users mailing list