Version française
Home     About     Download     Resources     Contact us    
Browse thread
problem with ocamlmktop -output-obj
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Thierry Bravier <thierry.bravier@d...>
Subject: Re: problem with ocamlmktop -output-obj
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.
> 
> Hope this helps,
> 
> - Xavier Leroy

Thank you for answering

I must now face a problem:

Thierry Bravier wrote:
> 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

It would be really nice if I could use -custom but ...
 
How can I ask ocamlc -custom to :
1) use a user-provided compiled main() (potentially compiled with C++)
2) link with a user-provided linker (aka g++)
3) I know that internally, some C code is output and compiled
   (for the external primitives I think), I think this code should
   still be compiled with the C compiler used to build ocaml.

Are there any clues to help me build this toplevel with C++ code
without -output-obj ?

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