
There's been a bit of traffic about calling Haskell from C++ recently,
and I know that calling C++ from Haskell is a frequently asked question.
(E.g. Koen Claessen was asking me about it this week.) It also seems to
be somewhat platform dependent. (Esp on Windows, I think.)
Would someone like to write up a description of how
to successfully call out from Haskell to C++ and vice versa,
using GHC?
If you did, we'd gladly include the result in the user manual, and save
others a lot of head scratching. Maybe there are simple things we could
do to GHC to make the process simpler. But what it needs is someone who
knows C++ well to write a coherent story. Please!
Simon
________________________________
From: glasgow-haskell-users-bounces@haskell.org
[mailto:glasgow-haskell-users-bounces@haskell.org] On Behalf Of Rich
Neswold
Sent: 13 September 2005 16:45
To: Felix Breuer
Cc: glasgow-haskell-users@haskell.org
Subject: Re: FFI: calling Haskell from C++?
On 9/13/05, Felix Breuer

On 9/14/05, Simon Peyton-Jones
There's been a bit of traffic about calling Haskell from C++ recently, and I know that calling C++ from Haskell is a frequently asked question.
Would someone like to write up a description of how to successfully call out from Haskell to C++ and vice versa, using GHC? If you did, we'd gladly include the result in the user manual, and save others a lot of head scratching. Maybe there are simple things we could do to GHC to make the process simpler. But what it needs is someone who knows C++ well to write a coherent story. Please!
I'm flattered that you quoted my message, but I'm not familiar with the foreign language interface; I started looking at Haskell only a few weeks ago. I was able to fix the first problem, since the name-mangler is always a problem when mixing other languages with C++. The second error I may or may not have got right. The other solution recommended that the C++ library be linked which fixes the undefined exception handling symbols. I'm curious what would happen if Haskell called down into C++ code and then an exception was thrown... Anyways, I think your suggestion is a good one and I would be willing to answer any C++ questions that anyone has when writing such a document. -- Rich AIM : rnezzy ICQ : 174908475

On Wed, 14 Sep 2005 16:05:26 +0100
"Simon Peyton-Jones"
Would someone like to write up a description of how
to successfully call out from Haskell to C++ and vice versa,
using GHC?
I could write up a summary of our experiences calling Haskell from C++, but as I have no in depth knowledge of the interna, that summary would be anything but comprehensive, so I am not sure I am the right man for the job. Right now we have to use GHC to link the entire project (including the C++ part) because we have to rely on --make to figure out which GHC libraries (i.e. which .o files in /usr/lib/ghc-6.4) we need to link against. We would like to do the linking manually (via g++). Now: * Is there a way to have GHC link only the Haskell part of the project (including libraries) and create an .o file? * Alternatively: Is there a way to have GHC return dependency information _including_ information about GHC libs? (I know about -M but that does not include info about needed libraries) Thanks, Felix
participants (3)
-
Felix Breuer
-
Rich Neswold
-
Simon Peyton-Jones