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

John Velman velman at cox.net
Tue Oct 6 19:20:31 EDT 2009

Thanks, Gregory.  I did something like that.  In particular, I did

find . -name "lib*.a" | xargs nm > ~/develop/haskellLibInfo/libInfo

Then I used the output from the build results file to look for stuff in the
libInfo file (using mac_vim).  In this way I cut the number of undefined
references down to 17 (from 56).  The remaining references all seem (from
the nm results) to be in libgmp.a, which I included in the project early
in this experiment.  The remaining ones are, for example:



  All are of the __gmpz variety.

So far all that I've looked in my libInfo have entries something like: 

     00000000 T ___gmpz_tdiv_qr

I'm way out of my depth here.  Here is a list of files I included in the
project from 

 so far:

  HSghc-prim-,     HSinteger-,   libffi.a,   libgmp.a,
  libHSbase-,   libHSbase-,   libHSbase-,
  libHSghc-prim-,   libHSrts.a 

I'm using Haskell installed from

haskell-platform-2009.2.0.2-i386.dmg (for OS X).

Well, any further pointers will be highly appreciated.

I'll have to sign off from this today, but hopefully will have more
insights (from self and others) tomorrow.


John Velman

On Tue, Oct 06, 2009 at 03:07:01PM -0400, Gregory Collins wrote:
> John Velman <velman at cox.net> writes:
> > 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?
>     $ cd /Library/Frameworks/GHC.framework/Versions/Current/usr/lib/
>     $ for i in `find . -name '*.a'`; do nm -a $i 2>/dev/null | grep --label="$i" -H 'D *_base_GHCziBase_plusInt_closure'; done
>     ./ghc-6.10.4/base- D _base_GHCziBase_plusInt_closure
>     ./ghc-6.10.4/base- D _base_GHCziBase_plusInt_closure
> G.
> -- 
> Gregory Collins <greg at gregorycollins.net>

More information about the Haskell-Cafe mailing list