From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: weis Received: (from weis@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id UAA24412 for caml-redistribution@pauillac.inria.fr; Mon, 17 Apr 2000 20:52:28 +0200 (MET DST) Resent-Message-Id: <200004171852.UAA24412@pauillac.inria.fr> Received: from concorde.inria.fr (concorde.inria.fr [192.93.2.39]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id PAA21550 for ; Sun, 16 Apr 2000 15:40:49 +0200 (MET DST) Received: from cs.huji.ac.il (cs.huji.ac.il [132.65.16.10]) by concorde.inria.fr (8.8.7/8.8.7) with ESMTP id PAA17155 for ; Sun, 16 Apr 2000 15:40:48 +0200 (MET DST) Received: from zigzag.cs.huji.ac.il ([132.65.208.204]) by cs.huji.ac.il with esmtp (Exim 3.10 #1) id 12gpI7-0005g1-00 for caml-list@inria.fr; Sun, 16 Apr 2000 16:40:47 +0300 Received: (from orodeh@localhost) by zigzag.cs.huji.ac.il (8.9.3/1.1c) id QAA11323; Sun, 16 Apr 2000 16:40:47 +0300 Date: Sun, 16 Apr 2000 16:40:44 +0300 (IDT) From: Ohad Rodeh To: caml-list@inria.fr Subject: Calling C++ from Caml Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Resent-From: weis@pauillac.inria.fr Resent-Date: Mon, 17 Apr 2000 20:52:28 +0200 Resent-To: caml-redistribution@pauillac.inria.fr Hello, 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: dh.ml : 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 _ = dhml_Try(); () The compilation seqeunce is as follows: c++ -c -w -I$(CAMLLIB) xx.cpp -o xx.o ocamlc -c dh.ml 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? Thanks, Ohad.