#5574: undefined reference to `ZCMain_main_closure' and undefined reference to
`__stginit_ZCMain' collect2:
--------------------------+-------------------------------------------------
Reporter: francisco | Owner:
Type: bug | Status: closed
Priority: normal | Component: Compiler
Version: 7.0.3 | Resolution: invalid
Keywords: | Testcase:
Blockedby: | Os: Linux
Blocking: | Architecture: x86
Failure: None/Unknown |
--------------------------+-------------------------------------------------
Changes (by daniel.is.fischer):
* status: new => closed
* resolution: => invalid
Comment:
The problem is
{{{
module TorresHanoiMenu where
}}}
To produce an executable, there must be an entry point, for which special
code has to be generated so that it can be called from outside Haskell. By
default, that entry point is the function `main` in module `Main`. If
there is no `module Main`, ghc doesn't create an executable. If there is a
`Main` module, but no function `main` in that, ghc (--make) aborts the
compilation.
Unless the function to use as entry point has been explicitly specified
via the `-main-is` option.[[BR]]
You can pass a function name (`foo`), a module name (`Bar`) or a qualified
function name (`Baz.boing`) as an argument to that option, making the
entry point `Main.foo`, `Bar.main` resp. `Baz.boing`.
In your case, you could a) rename the module to `Main` b) compile with
either of
{{{
$ ghc -O --make -o menu -main-is TorresHanoiMenu.main TorresHanoiMenu.hs
$ ghc -O --make -o menu -main-is TorresHanoiMenu TorresHanoiMenu.hs
}}}
(for ghc 7.0.1 or later, the `--make` isn't necessary anymore).
Since ghc didn't create any special code for an entry point, the linker
couldn't find it, hence the undefined references.
--
Ticket URL: <http://hackage.haskell.org/trac/ghc/ticket/5574#comment:2>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler
_______________________________________________
Glasgow-haskell-bugs mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs