Re: problem with ocamlmktop -output-obj

From: luther@maxime.u-strasbg.fr
Date: Wed Nov 04 1998 - 17:12:53 MET


From: luther@maxime.u-strasbg.fr
Date: Wed, 4 Nov 1998 17:12:53 +0100
To: caml-list@inria.fr
Subject: Re: problem with ocamlmktop -output-obj
In-Reply-To: <19981015192243.14795@pauillac.inria.fr>; from Xavier Leroy on Thu, Oct 15, 1998 at 07:22:43PM +0200

On Thu, Oct 15, 1998 at 07:22:43PM +0200, Xavier Leroy wrote:
> > 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 ?
>
> Toplevels need access to their own symbol table, and they look inside
> their executable file to find it. The symbol table information is not
> available if -output-obj is selected.
>
> A regular bytecode executable file is composed of several sections:
> code, data, symbols, and debug info. Currently, only the first two
> are available when a C object is generated instead of a regular
> executable file.
>
> For the same reasons, you can't debug a Caml program built with
> -output-obj.

Je pense que j'ai un probleme similaire.
I think i have a similar problem.

Je veut utiliser plus d'un source ocaml embarque dans du C.
i want to use more than one ocaml source file embedded in C.

donc je prend l'exemple de la doc, j'ajoute un other.ml contenant :
so i take the example, and add an other.ml file containing :

        let my_format_result n = Printf.sprintf "Result is: %d\n" n
                
et modifie mod.ml comme suit :
and modify mod.ml as follows :

        (* File mod.ml -- some ``useful'' Caml functions *)
        
            let rec fib n = if n < 2 then 1 else fib(n-1) + fib(n-2)
        
            let format_result n = Other.my_format_result n
                
        (* Export those two functions to C *)
        
        let _ = Callback.register "fib" fib
        let _ = Callback.register "format_result" format_result
                                        
et a la compilation j'ai le probleme suivant :
and when compiling i have the following error :

        ocamlc -custom -output-obj -o other.o other.ml
        ocamlc -custom -output-obj -o modcaml.o modcaml.ml
        Error while linking modcaml.cmo: Reference to undefined global `Other'

Est-il possible de compiler plusieurs source ocaml, en une librairie .cma par
exemple, puis de faire un -output-obj de celle-ci ? Est ce que cela resoudrait
le probleme ? Ou alors dois-je creer un fichier source geant, et transformer
mon other.ml en module Other = struct (contenu de other.ml) end, eventuellement
automatiquement ? Pas tres joli, mais cela marche.

IS it possible to compile more than 1 caml source, as a .cma library for
example, and then embedd it in C code ? will this solve my problem, or should i
do alone giant caml source file that include all other source files as modules
?

Amicalement,

Sven LUTHER



This archive was generated by hypermail 2b29 : Sun Jan 02 2000 - 11:58:16 MET