caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* problem with ocamlmktop -output-obj
@ 1998-10-14 16:47 Thierry Bravier
  1998-10-15 17:22 ` Xavier Leroy
  0 siblings, 1 reply; 9+ messages in thread
From: Thierry Bravier @ 1998-10-14 16:47 UTC (permalink / raw)
  To: caml-list; +Cc: ac-ca, basile.starynkevitch, Emmanuel.Dorlet

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 <stdio.h>
#include <caml/mlvalues.h>
#include <caml/callback.h>
 
/* =============================================================== */
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





^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~1998-11-05  7:45 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1998-10-14 16:47 problem with ocamlmktop -output-obj Thierry Bravier
1998-10-15 17:22 ` Xavier Leroy
1998-10-16 10:40   ` Thierry Bravier
1998-10-26 16:03     ` Thierry Bravier
1998-10-30 10:17       ` Pascal Brisset
1998-10-30 17:56         ` problem with ocamlmktop (contd) Pascal Brisset
1998-11-03  9:32           ` Pascal Brisset
1998-11-04 17:56           ` Thierry Bravier
1998-11-04 16:12   ` problem with ocamlmktop -output-obj luther

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).