I now know why there's no binding to FTGL nor to GLTT

I wanted to make a binding to FTGL or GLTT, or the other one, I don't remember the name. Those all are for C++, not for C. Is there a way? I really don't know anything about calling C++ from C. Is there some way to make haskell bindings for a C++ library? Am I stuck in a dead end? Already? Vincenzo

Nick Name wrote:
[...] Is there a way? I really don't know anything about calling C++ from C. Is there some way to make haskell bindings for a C++ library? Am I stuck in a dead end? Already?
The current FFI doesn't support C++, nevertheless there is a slightly tedious, but doable way around this: Write a thin wrapper with C linkage around the C++ stuff, using your favourite C++ compiler, e.g. extern "C" double foo(int x) { ... } is callable via the normal foreign import ccall foo :: CDouble -> CInt (add "unsafe" or IO, depending on the nature of foo). Cheers, S.

Write a thin wrapper with C linkage around the C++ stuff, using your favourite C++ compiler, e.g.
What do I have to distribute then? The C wrapper in the source, of course, but if I want a binary distribution, what do I do? Maybe I have to link the wrapper with the main program, but I've read that the main() function needs to be compiled with the C++ compiler for static initializations, how can I do this if the main is an haskell program? Vincenzo
participants (2)
-
Nick Name
-
Sven Panne