ghc7, -rtsopts, and g++

Evan Laforge qdunkan at
Thu May 5 18:24:16 CEST 2011

So as everyone probably knows, ghc7 requires -rtsopts to enable +RTS
parsing.  Apparently this makes it include various header files in
rts/ when linking, because after upgrading to ghc7 I suddenly got
syntax errors from headers there.  Some investigation revealed that
the problems were use of 'new' as a variable name in
rts/storage/Block.h, and implicit conversion from a bool to an enum
rtsBool in rts/ClosureMacros.h.  These things are fine in C, but not
in C++, and I'm linking with -pgmc g++ -pgml g++ so they were a
problem.  I was able to fix them by simply renaming 'new' and
replacing the implicit conversion with explicit.

But it makes me think setting g++ for the "C" compiler was incorrect.
I'm linking with c++ code via a wrapper that uses 'extern "C" { ... }'
to ensure the haskell FFI knows how to call it, and if I don't set
pgmc then the link dies horribly and very verbosely when none of the
c++ symbols are visible.  So I arrived at that flag by guessing after
my program wouldn't link without it, not because I saw documentation
saying this is how to do it.

Is there a better way to link to c++?

More information about the Glasgow-haskell-users mailing list