
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

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
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@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe

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
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@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe

You are missind libHSbase. Try, for example:
locate libHSbase-3.0.1.0.a
and link that in.
Thomas
On Tue, Oct 6, 2009 at 11:51 AM, John Velman
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
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@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe

John Velman
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-4.1.0.0/libHSbase-4.1.0.0.a:0000008c D _base_GHCziBase_plusInt_closure
./ghc-6.10.4/base-4.1.0.0/libHSbase-4.1.0.0_p.a:0000010c D _base_GHCziBase_plusInt_closure
G.
--
Gregory Collins

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: "___gmpz_init", "___gmpz_divexact", "___gmpz_tdiv_qr" ... 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 /Library/Frameworks/GHC.framework/Versions/610/usr/lib/ghc-6.10.4/... so far: 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 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. Best, John Velman On Tue, Oct 06, 2009 at 03:07:01PM -0400, Gregory Collins wrote:
John Velman
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-4.1.0.0/libHSbase-4.1.0.0.a:0000008c D _base_GHCziBase_plusInt_closure ./ghc-6.10.4/base-4.1.0.0/libHSbase-4.1.0.0_p.a:0000010c D _base_GHCziBase_plusInt_closure
G. -- Gregory Collins

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@kf8nh.com system administrator [openafs,heimdal,too many hats] allbery@ece.cmu.edu electrical and computer engineering, carnegie mellon university KF8NH

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@kf8nh.com system administrator [openafs,heimdal,too many hats] allbery@ece.cmu.edu electrical and computer engineering, carnegie mellon university KF8NH
[previous messages snipped to save virtual paper]

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@kf8nh.com system administrator [openafs,heimdal,too many hats] allbery@ece.cmu.edu electrical and computer engineering, carnegie mellon university KF8NH
[previous messages snipped to save virtual paper] _______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe

On 7 Oct 2009, at 23:39, John Velman wrote:
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].
Is there any chance you'll write up exactly what you needed to do on a blog/TMR article/Haskell wiki page? I've tried doing something similar, ran into linking problems, and gave up my fight with XCode. I think this would be a really useful resource for both Obj-C programmers looking into Haskell and Haskell programmers who want to have a fancy Cocoa GUI. Thanks! Wouter

On Thu, Oct 08, 2009 at 10:34:07AM +0200, Wouter Swierstra wrote:
On 7 Oct 2009, at 23:39, John Velman wrote:
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].
Is there any chance you'll write up exactly what you needed to do on a blog/TMR article/Haskell wiki page? I've tried doing something similar, ran into linking problems, and gave up my fight with XCode. I think this would be a really useful resource for both Obj-C programmers looking into Haskell and Haskell programmers who want to have a fancy Cocoa GUI. Thanks!
Wouter
Yes, it is my intention to do just that. Unfortunately, I don't always follow through! But with a specific request, I'll try to get it done in the next few days. I'll post the url here. Best, John Velman

It's taken 21 days with interruptions, but I finally posted a tutorial with details of what I did on the Haskel Wiki. Category:Tutorials, title: Using Haskell in an Xcode Cocoa project Hope it's clear. Please send comments and suggestions. John V. On Thu, Oct 08, 2009 at 10:34:07AM +0200, Wouter Swierstra wrote:
On 7 Oct 2009, at 23:39, John Velman wrote:
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].
Is there any chance you'll write up exactly what you needed to do on a blog/TMR article/Haskell wiki page? I've tried doing something similar, ran into linking problems, and gave up my fight with XCode. I think this would be a really useful resource for both Obj-C programmers looking into Haskell and Haskell programmers who want to have a fancy Cocoa GUI. Thanks!
Wouter

I can confirm that, if you follow the steps on the wiki, you'll end up with a working Mac application. Excellent work John, thanks very much! -chris On 30 okt 2009, at 00:53, John Velman wrote:
It's taken 21 days with interruptions, but I finally posted a tutorial with details of what I did on the Haskel Wiki. Category:Tutorials, title: Using Haskell in an Xcode Cocoa project
Hope it's clear. Please send comments and suggestions.
John V.
On Thu, Oct 08, 2009 at 10:34:07AM +0200, Wouter Swierstra wrote:
On 7 Oct 2009, at 23:39, John Velman wrote:
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].
Is there any chance you'll write up exactly what you needed to do on a blog/TMR article/Haskell wiki page? I've tried doing something similar, ran into linking problems, and gave up my fight with XCode. I think this would be a really useful resource for both Obj-C programmers looking into Haskell and Haskell programmers who want to have a fancy Cocoa GUI. Thanks!
Wouter
_______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
participants (6)
-
Brandon S. Allbery KF8NH
-
Chris Eidhof
-
Gregory Collins
-
John Velman
-
Thomas DuBuisson
-
Wouter Swierstra