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

John Velman velman at cox.net
Wed Oct 7 17:39:27 EDT 2009


For anyone following this:  The XCode ld script is complex, and has mac
specific defaults early in the search path specification, and I probably
don't want to change these.  A library in a default path is the wrong
libgmp.[dylib | a].  

My solution:
do a

ln -s libgmp.a lib-h-gmp.a 

in the /Library/Frameworks/GHC.Framework/..../usr/lib folder.

Then add lib-h-gmp.a to my Xcode project.

Compiled, linked, and ran and got the right output.

Thanks to everyone who helped.

John V.

On Wed, Oct 07, 2009 at 10:38:53AM -0700, John Velman wrote:
> This is probably an Xcode problem now, rather than a strictly Haskell
> problem.  
> 
> There are a bunch of libgmp.a and libgmp.dylib files in existence on this
> computer, some in /usr/local/lib, or linked from there.
> 
> I've got my errors down to references in libgmp, whether or not I try to
> include libgmp.a in the project.
> 
> Whenever I try to add libgmp.a, or libgmp.dylib to my project, I get the
> error message:
> 
> ----------
> ld warning: 
>  in /Developer/SDKs/MacOSX10.5.sdk/usr/local/lib/libgmp.dylib, 
>  file is not of required architecture
> ---------
> 
> followed by a list of undefined symbols, all of which (well, all I've
> checked!) are defined in the Haskell Platform version of libgmp.a
> 
> I'm sure there must be a way around this in the Xcode IDE, but haven't
> found it.  I'll take the question to the Xcode mailing list.
> 
> Thanks to all for help on this.  I'll let you know how it works out!
> 
> Best,
> 
> John Velman
> 
> 
> 
> On Tue, Oct 06, 2009 at 07:56:07PM -0400, Brandon S. Allbery KF8NH wrote:
> > On Oct 6, 2009, at 19:20 , John Velman wrote:
> >>  HSghc-prim-0.1.0.0.o,     HSinteger-0.1.0.1.o,   libffi.a,   libgmp.a,
> >>  libHSbase-3.0.3.1.a,   libHSbase-3.0.3.1_p.a,   libHSbase-4.1.0.0.a,
> >>  libHSghc-prim-0.1.0.0_p.a,   libHSrts.a
> >
> > Note that library order matters; libgmp.a should probably be last on the 
> > command line.
> >
> > -- 
> > brandon s. allbery [solaris,freebsd,perl,pugs,haskell] allbery at kf8nh.com
> > system administrator [openafs,heimdal,too many hats] allbery at ece.cmu.edu
> > electrical and computer engineering, carnegie mellon university    KF8NH
> >
> [previous messages snipped to save virtual paper]
> _______________________________________________
> 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