Version française
Home     About     Download     Resources     Contact us    

This site is updated infrequently. For up-to-date information, please visit the new OCaml website at

Browse thread
Calling C++ from Caml
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 2000-04-17 (18:52)
From: Ohad Rodeh <orodeh@c...>
Subject: Calling C++ from Caml
  I'm trying to use C++ code from within Caml. Currently,
the compiler cannot find the requested functions in the compiled
C++ code. 

  A very simple example fails. I have two files: : ML code
xx.cpp : C++ code

The C++ code contains the function:
	value dhml_Try(value dummy) {
	   return Val_unit;
The ML code calls dhml_Try using:
	external dhml_Try : unit -> unit 
	  = "dhml_Try"

	let _ = 

The compilation seqeunce is as follows:
	c++ -c -w -I$(CAMLLIB) xx.cpp -o xx.o
	ocamlc -c
	ocamlc -cc c++ -custom -o dh  xx.o dh.cmo	
/tmp/ccEPQ4W1.o(.data+0x248): undefined reference to `dhml_Try'

  If I use the gcc compiler with C code, instead of C++, this 
sequence works fine. How can I fix this problem?