[Haskell-cafe] Calling Haskell from C, Linking with gcc?

John Velman velman at cox.net
Tue Oct 6 12:44:16 EDT 2009

I think if I knew which libraries to add to the gcc link, I could make this
work, but can't seem to find out from the documentation.

Here are more specifics:

I'd like to build a Cocoa  program on OS X with the Aqua user interface
using Xcode, but using a Haskell module with functions accessed through the
foreign export  interface.  In fact this seems to fit in well with the
Apple Model-View-Control programming pattern, with Haskell implementation
of the Model, maybe some of the Control,  and Cocoa implementation of the
View and some of the Control.

I've put together a short program (from the Wiki calling Haskell from C
example) and compiling and linking with ghc it runs as advertised.

As an experiment, I put the c main program into an Xcode project, added the
haskell module .o and stub.o, stub.h files.  Also added the HsFFI.h.  Then
did a build and run.  As expected I got a bunch of missing entry points
(26, if I recall correctly).  Adding libffi.a and libHSrts.a brings me up
to 56 missing entry points. Searching the other lib files for these seems
pretty hopeless.

Any pointers to documentation, or other help will be greatly appreciated!


John Velman

More information about the Haskell-Cafe mailing list