[Haskell] Building a dynamic loadable Parsec parser

Adam Turoff adam.turoff at gmail.com
Mon Feb 28 13:15:28 EST 2005


I've got a little parser written using Parsec that I want to link into
some C code.  I start by compiling the Haskell sources like so:

	ghc -ffi -fglasgow-exts -main-is My_Init -c parse.hs

When linking parse.o and parse_stub.o against my (additional) glue code,
I get the following errors:

	Main.o(.text+0xc): undefined reference to `__stginit_ZCMain'
	Main.o(.text+0x14): undefined reference to `__stginit_ZCMain'
	Main.o(.text+0x20): undefined reference to `ZCMain_main_closure'
	Main.o(.text+0x24): undefined reference to `ZCMain_main_closure'

I'm trying to build a .so that I can load into another process (via Tcl,
actually).  If I define a main function in my C glue code, these errors
go away.  But I can't have a main function in this .so.

So, two questions:
	- is it possible to compile and link these .o files into a .so
	  (on Solaris, using ghc 6.2.2)?
	- what do I need to do to create an entry point for this Haskell
	  code that _isn't_ called main()?


-- Adam

More information about the Haskell mailing list