I use c2hs for easing the process of writing Haskell bindings to C/C++ libraries. I also recently started using stack for managing my Haskell projects.
To use c2hs, I need to have a line saying #include "myheader.h"
inside my Haskell source code; here myheader.h
is the interface file to my C/C++ libraries.
I found out today, that instead of embedding this #include
line into the .chs
source file, one can also pass the location of the header file while invoking c2hs as follows
c2hs /<path-to-my-header>/myheader.h Foo.chs
Thankfully, stack automatically detects when a file has a .chs extension and then calls c2hs on it. My question is, how do I tell stack to pass this extra command-line argument (i.e. the location of the header-file) while calling c2hs? What changes will I need to make to my .cabal or my stack.yaml file?
Adding your location in the include-dirs
field under the library or executable section (depending on your project) in the cabal file should make it work.