FFI & C++

Alastair Reid alastair@reid-consulting-uk.ltd.uk
29 Oct 2002 19:10:32 +0000

> Hi, I am currently trying to create a Haskell interface to a C++
> library and cannot get it to work completely.

If you want to interface Hugs to C++ code, you have to link Hugs using
a C++ compiler so that the Hugs binary contains new, throw, etc.  I
believe the main thing this changes is that some extra libraries are
linked into the binary.

Obviously, the story is a bit different for GHC but you probably want to either:

1) Tell GHC to use a C++ compiler as its linker; or

2) Figure out what libraries C++ adds in (e.g., compare what g++ -v
   and gcc -v do with hello world) and tell GHC to use them when linking.

Alastair Reid                 alastair@reid-consulting-uk.ltd.uk  
Reid Consulting (UK) Limited  http://www.reid-consulting-uk.ltd.uk/alastair/