Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

haskell

ghc

cabal

I have a c library that I'd like to provide an FFI interface for. This is easy enough, but I can't figure out how to get the packaging right. It would be nice to just be able to

cabal install librarybindings

and have cabal automatically build it with gcc, generate the .o file, and include that with the distribution. Right now, I can the package to compile fine, but when you go to build an executable using the bindings you have to explicitly pass ghc the .o file on the command line. Yuck.

like image 276
Mike Izbicki Avatar asked Aug 15 '13 18:08

Mike Izbicki


1 Answers

Yes, you can ship C code with Haskell. See e.g.

  • bytestring
  • zlib
  • download

By convention the C bits are put in a cbits/ directory.

like image 142
Don Stewart Avatar answered Nov 05 '22 09:11

Don Stewart