Cabal vs. C++

Roman Leshchinskiy rl at cse.unsw.edu.au
Tue Feb 26 03:38:36 EST 2008


What is the simplest way to build a Haskell project that uses a C++ 
library? It needs at least the following from Cabal.

   - It must know how to compile C++ files. This kind of works by
     accident if I list those under c-sources since gcc knows what to do
     with them but this is (a) ugly and (b) doesn't allow me to pass
     C++-specific options to gcc.

   - The project must be linked with g++. However, I don't understand how
     to tell Cabal which linker to use. I got as far as

       main = defaultMainWithHooks
            $ defaultUserHooks
               { hookedPrograms = [Program "ld" (findProgramOnPath "g++")
                                                (\_ _ -> return Nothing)]

     but this doesn't seem to work. configure --with-ld=g++ does, but
     it's not nice.

Is there any simple way of making this work or do I have to use 
makefiles? Also, is it intentional that Cabal ignores standard 
environment variables such as CC, CFLAGS etc.?

Roman



More information about the Libraries mailing list