
Hello everyone, we have tried long and hard to call Haskell functions from C++ using the FFI mechanism but without success. Our problem is as follows: We tried the C case first. Taking the example code from Chapter 8.2 of the GHC User Guide, we created files Foo.hs and main.c and then did $ ghc -fffi -c Foo.hs /tmp/ghc28407.hc: In function `__stginit_Foo_': /tmp/ghc28407.hc:278: warning: implicit declaration of function `getStablePtr' $ ghc -fffi Foo. Foo.hi Foo.hs Foo.o $ mv main.cpp main.c $ ghc -fffi Foo.o Foo_stub.o main.c $ ./a.out 2500 2500 2500 2500 2500 which worked fine. But when we simply rename main.c -> main.cpp, then $ ghc -fffi Foo.o Foo_stub.o main.cpp main.o(.text+0x22): In function `main': main.cpp: undefined reference to `__stginit_Foo()' main.o(.eh_frame+0x11): undefined reference to `__gxx_personality_v0' collect2: ld returned 1 exit status We tried many different options to ghc and also using g++ directly, all to no avail. It would be really great if someone could shed some light on this. For convenience, we have attached Foo.hs and main.cpp. Thanks, Felix