Help in calling Haskell from C

Mark Conway Wirt
Tue, 14 Aug 2001 11:49:08 -0400

I've been using hdirect for C <-> Haskell calls, and I've hit a bit
of a snag.  I'm using ghc 5.00.2 and hdirect 0.17.

I've been able to call Haskell from C easily enough, but I've been
unable to go the other way.

I've tried following the directions in the hdirect manual, and tried
building the examples in the hdirect distribution.  Everything works
up until final linking, where I receive undefined references.

The C code should initialize the Haskell run-time, as it include the
startup code:

    extern void startupHaskell (int argc, char* argv[]);

I'm compiling via ghc with the following options:

    ghc -package hdirect -fglasgow-exts -static -no-hs-main 

and the idl is compiled as such:

ihc -s -fhs-to-c --gen-headers -fuse-ints-everywhere --output-h=....

Does hdirect work with ghc 5.00.2?  I'm not receiving any errors in the
build process, so I think my problems are more related to a lack of
documentation, as opposed to a bug.  Does anyone have any information
(beyond what is in the hdirect documentation) on calling ghc-compiled
code from C?

The undefined references I'm getting are:

     undefined reference to `__init_Main'
     undefined reference to `Main_main_closure'

Thanks in advance.  I've looked though the mailing list archive and
haven't found anything.  If this has been answered before I apologize.