Re: compiling problem on Sven's tutorial sample

Sven Panne <[email protected]>
Newsgroups gmane.comp.lang.haskell.hopengl
Message-ID <[email protected]>
Shiqi Cao wrote:
> I tried to compile the sample code in Sven's tutorial. 
> 
> root@linux Haskell # ghc -package GLUT -o test3 test3.o
> /usr/lib/ghc-6.2/libHSrts.a(Main.o)(.text+0x10): In function `main':
> : undefined reference to `__stginit_ZCMain'
> /usr/lib/ghc-6.2/libHSrts.a(Main.o)(.text+0x36): In function `main':
> : undefined reference to `ZCMain_main_closure'
> collect2: ld returned 1 exit status
> root@linux Haskell #
> 
> module GLtest where
> [...]

Under normal circumstances, the main function of a Haskell program has
to be called "main" and must reside in module "Main". So you have different
options to fix your problem:

    * Use "Main" instead of "GLtest"

    * Leave out the "module" line completely, so you use "Main" implictly.
      This is done in the tutorial, BTW.

    * Use GHC's "--main-is GLtest" option, see:

         http://haskell.org/ghc/docs/latest/html/users_guide/options-phases.html#OPTIONS-LINKER

Cheers,
    S.
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.