I have a Haskell program using the FFI to import C++ functions. I'm using Windows. When I compile to an executable or to a DLL, this works. But when I load a module in GHCI, this doesn't always work: sometimes this works, sometimes I get Access violation in generated code when reading 0000000000000000 whenever I call a function from the module (even if this function has nothing to do with the C++). Do you know how to prevent that?
Asked
Active
Viewed 401 times
0
-
1This is quite vague - you ahould include a minimal example which shows the problem. Note, for FFI to work at all in GHCi you must pass `-fobejct-code`. However, without this option the error you will get is different, so I don't know if this is your problem. – user2407038 Dec 16 '17 at 21:13
-
@user2407038 Yep, sorry for the vagueness but this problem doesn't occur for a small code. My code is [here](https://github.com/stla/owenqp) but I'm afraid nobody will look at such a piece of code. – Stéphane Laurent Dec 16 '17 at 21:55
-
@StéphaneLaurent, if small code works, and large code doesn't, start simplifying the large code you have until it works. It might even show you exactly what the problem is – luqui Dec 17 '17 at 02:11
-
@luqui That's what I did previously. But that does not lead to anything because of the random behavior. Currently my program works like a charm in GHCI. – Stéphane Laurent Dec 17 '17 at 03:30
-
@StéphaneLaurent, oh man, I didn't notice "doesn't always work". Maybe try loading up `ghci` in `gdb` so you can see where it goes wrong specifically (hoping that it's in the C++ code)? – luqui Dec 17 '17 at 06:11