Is it possible to pack c code with Haskell using cabal?

I have a c library that I would like to provide for the FFI interface. It’s easy enough, but I can’t figure out how to get the package right. It would be nice to just be able to

cabal install librarybindings 

and it will automatically create it using gcc, generate the .o file and include it in the distribution. I can compile the package right now, but when you go to build the executable using the bindings, you must explicitly pass the ghc .o file on the command line. Ugh.

+7
haskell ghc cabal
source share
1 answer

Yes, you can send C code using Haskell. See, for example,

By convention, the C bit is placed in the cbits / directory.

+5
source share

All Articles