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 QAA04529 for caml-redistribution; Thu, 15 Oct 1998 16:06:21 +0200 (MET DST) Received: from nez-perce.inria.fr (nez-perce.inria.fr [192.93.2.78]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id SAA19843 for ; Wed, 14 Oct 1998 18:43:08 +0200 (MET DST) Received: from relay5.eunet.fr (relay5.eunet.fr [193.107.193.102]) by nez-perce.inria.fr (8.8.7/8.8.7) with SMTP id SAA24062 for ; Wed, 14 Oct 1998 18:43:06 +0200 (MET DST) Received: from relay2.eunet.fr by relay5.eunet.fr (5.65c8d/96.05.03) via EUnet-France id AA26088; Wed, 14 Oct 1998 17:43:17 +0100 (MET) Received: from dassav (dassav.dassault-aviation.fr [193.106.72.131]) by relay2.eunet.fr (8.8.5/8.8.5) with SMTP id SAA11567; Wed, 14 Oct 1998 18:42:14 +0100 (MET) Received: from fnet-ia1.dassault-aviation.fr by dassav (5.x/SMI-SVR4) id AA26380; Wed, 14 Oct 1998 17:35:41 +0100 Received: from fnet-ia2.fnet-ia by fnet-ia1.dassault-aviation.fr (SMI-8.6/SMI-SVR4) id SAA21376; Wed, 14 Oct 1998 18:47:28 +0200 Received: from fnet-ia2 by fnet-ia2.fnet-ia (SMI-8.6/SMI-SVR4) id SAA03002; Wed, 14 Oct 1998 18:47:59 +0200 Sender: weis Message-Id: <3624D5BE.3060@dassault-aviation.fr> Date: Wed, 14 Oct 1998 18:47:58 +0200 From: Thierry Bravier Organization: Dassault Aviation DGT/DPR/DESA X-Mailer: Mozilla 3.01Gold (X11; I; SunOS 5.5.1 sun4c) Mime-Version: 1.0 To: caml-list@inria.fr Cc: ac-ca@imaginet.fr, basile.starynkevitch@cea.fr, Emmanuel.Dorlet@cea.fr Subject: problem with ocamlmktop -output-obj Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Dear ocamlers, I have encountered a problem while trying to build a toplevel (ocamlmktop) linked with - external C code and - ML code compiled as a C object (-output-obj and implicitely -custom). I have no problem when I build an ordinary batch (non-toplevel) program. Is this a limitation of the system or I am doing it wrong ? Thanks. Thierry Bravier Dassault Aviation - DGT / DPR / DESA 78, Quai Marcel Dassault F-92214 Saint-Cloud Cedex - France Telephone : (33) 01 47 11 53 07 Telecopie : (33) 01 47 11 52 83 E-Mail : mailto:thierry.bravier@dassault-aviation.fr PS. Here are 3 small files demonstrating the issue. I understand it does not make sense to use -output-obj just to call printf from C. In fact, I use it to link ML and C++ code; in this case, C++ needs to compile main() and link itself (as explained in the manual section `Embedding the Caml code in the C code', ordinary -custom wants to link but -output-obj builds a linkable .o file which seems to fit my needs) PS2: I work on solaris % uname -a SunOS scdprs20 5.5.1 Generic sun4u sparc SUNW,Ultra-2 /* ================================================================== * File: mail_main.c * =============================================================== */ #include #include #include /* =============================================================== */ int main (int argc, char **argv) { printf ("entering C\n"); caml_startup (argv); printf ("5! = %d\n", Int_val(callback(*caml_named_value("f"),Val_int(5)))); printf ("exiting C\n"); } /* =============================================================== */ (* ================================================================== * File: mail_prgm.ml * =============================================================== *) let _ = Printf.printf "entering ML\n" let rec f = function 0 -> 1 | n -> n * f (pred n) let _ = Callback.register "f" f let _ = Printf.printf "exiting ML\n" (* =============================================================== *) #!/bin/sh -x #==================================================================== # File: mail_build #==================================================================== STDLIB=/logiciel/GNU/LOCAL/ocaml/ocaml/stdlib # or whatever LDLIBS="-lcamlrun -ltermlib -lsocket -lnsl -lm" # or whatever CC=gcc # or whatever #==================================================================== ${CC} -c -I${STDLIB} mail_main.c ocamlc -c mail_prgm.ml ocamlc -output-obj -o mail_batch.o mail_prgm.cmo ocamlmktop -output-obj -o mail_toplevel.o mail_prgm.cmo ${CC} -o mail_batch -L${STDLIB} mail_main.o mail_batch.o ${LDLIBS} ${CC} -o mail_toplevel -L${STDLIB} mail_main.o mail_toplevel.o ${LDLIBS} #==================================================================== ./mail_batch # works as expected # entering C # entering ML # exiting ML # 5! = 120 # exiting C ./mail_toplevel # fails at runtime # entering C # Fatal error: uncaught exception Failure("input_value: bad object") #==================================================================== -- Thierry Bravier Dassault Aviation - DGT / DPR / DESA 78, Quai Marcel Dassault F-92214 Saint-Cloud Cedex - France Telephone : (33) 01 47 11 53 07 Telecopie : (33) 01 47 11 52 83 E-Mail : mailto:thierry.bravier@dassault-aviation.fr