Problems with main in a lib*.a. Is that a bug?

Simon Marlow
Wed, 11 Dec 2002 09:57:52 -0000

> I am building a SDL binding on MacOS X (but the same problem should=20
> appears on Windows). It defines it's own main function in a=20
> libSDLmain.a.
> But I can't get ghc not to generate a main when linking with=20
> -lSDLmain,=20
> which is the option that is indicated to get the main function that=20
> make SDL usable.
> when I link write :
> ghc -o test Main.hs libSDLmain.a , ghc doesn't generate a main as it=20
> can see there is a main in libSDLmain. And my test programs works.
> but when I write
> ghc -o test Main.hs -lSDLmain, ghc creates its own main, and=20
> it doesn't work.

Could you give more details?  What is the error message?

GHC doesn't generate main, there's a main function in libHSrts.a which
is linked in last, so that you can override it with your own.  You
should probably use -no-hs-main, too, otherwise the linker will require
that Main.main exists in the Haskell code.