I'm trying to make a data structure that will be exposed in Haskell, but implemented in C++. So far I've implemented it in a .cpp
file, declared all the functions I need as extern "C"
and added the source file to the c-sources
field in the .cabal
file. When I build the project (in this case with stack build
) it seems to build fine.
I know it's doing something to the C++ file because it doesn't compile if there are errors.
I've yet to try running the project because it's a library and so far it doesn't have anything "runnable" written, but the repl doesn't seem to work.
When I try running it (stack repl
in this case) I get a missing symbol error with some mangled name that may or may not be refer to a name in my file.
unknown symbol `_ZdlPv'
linking extra libraries/objects failed
How can I fix this issue? I've had a similar problem before that I fixed by manually compiling the source into a dynamic library and then use that library in my project. I don't want to do that since it ties me to a platform and since it makes no sense that a simple C++ couldn't be compiled with the project using the tools that GHC already has. I want to be able to put this on hackage.
Is there something I'm missing? If not, is it a bug and are there plans on fixing it?
Ok, I've managed to "fix" this for now.
I added a extra-libraries: stdc++-6, gcc_s_seh-1
to my cabal file and now it works. No idea if this is platform independant but those libraries do get shipped with GHC when I install it through stack.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With