linking with c++ libraries

Andrew J Bromage
Sat, 21 Jul 2001 15:35:22 +1000

G'day all.

On Sat, Jul 21, 2001 at 01:32:43AM +0800, Corneliu Popeea wrote:

> I'm trying to use from Haskell a C++ library (Omega Calculator).
> I'm using the following command:
> ghc -c -fglasgow-exts -package lang main.hs
> ghc main.o mylib.o -lomega -lstdc++ -fglasgow-exts -package lang
> Do I need to add more options?

To reliably link with C++, you need to compile both the code which
invokes C++ (i.e. whatever uses the C++ library) and "main" (that is,
ghc/rts/Main.c, not main.hs) with a C++ compiler.

So, in summary:

	- Compile any code which may call the C++ library (and keep
	  inter-module inlining in mind; probably safest to compile
	  all of your code this way) via C, and compile the C with g++.

	- Re-compile the run-time system (at least Main.c) with
	  g++, too.

That may not fix your specific core dump, but you'll need to do this

Andrew Bromage