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

John Velman velman at cox.net
Tue Oct 6 14:51:36 EDT 2009


On Tue, Oct 06, 2009 at 09:48:44AM -0700, Thomas DuBuisson wrote:


Thanks, Thomas.

Linking in only libffi.a, libgmp.a, I get (for example, there are many
more) missing:

  "_newCAF"  
  "_base_GHCziBase_plusInt_closure"
  "_base_GHCziList_zzipWith_info"
  "_base_GHCziList_lvl5_closure"

by also linking in libHSrts.a, I no longer am missing _newCAF, (and others
that were missing without it) but am missing a lot of _base_GHCzi...
references.  I've been unable to track these down.

By the way, I can't find either a libc.a or libm.a on this machine using
either locate or spotlight.

Is there a way to "guess" which library things are in, short of doing 
an nm with some appropriate option on each .a file in the Haskell lib?

Thanks,

John V.


> Generally you should be able to tell which library you're missing
> based on the names of the undefined symbols.  Have you link in...
> libgmp.a? libm.a? libc.a?  What are the missing symbols?
> 
> Thomas
> 
> On Tue, Oct 6, 2009 at 9:44 AM, John Velman <velman at cox.net> wrote:
> > 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!
> >
> > Thanks,
> >
> > John Velman
> >
> > _______________________________________________
> > Haskell-Cafe mailing list
> > Haskell-Cafe at haskell.org
> > http://www.haskell.org/mailman/listinfo/haskell-cafe
> >


More information about the Haskell-Cafe mailing list