Cabal vs. C++

Thomas Schilling nominolo at googlemail.com
Tue Feb 26 05:58:57 EST 2008


On 26 feb 2008, at 09.38, Roman Leshchinskiy wrote:

> 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.
>

I don't think you need to link with g++.  I successfully linked to a C 
++ library by adding -fexceptions to the linker options.  I used a  
makefile, but this should work with Cabal as well.

> 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
>
> _______________________________________________
> Libraries mailing list
> Libraries at haskell.org
> http://www.haskell.org/mailman/listinfo/libraries



More information about the Libraries mailing list