Dear all,

I want to trigger OCaml compilation programmatically from a C++ application and avoid the usage of subprocesses. It is fairly straightforward to generate an OCaml AST, but I cannot compile it.

1. The relevant modules/libraries do not load

  utop # #require "compiler-libs.optcomp";; 
  Error: Reference to undefined global `Location'

  X86_masm.generate_asm stdout [] ;;


2. The relevant modules seem to insist on file i/o for communication (i.e., they use out_channel objects)


Does anyone know a simple way around these issues?

a) Can I load the optcomp library without modifying the compiler (or with some simple modifications)

b) Is there a way to create an out_channel  from a memory buffer?

thanks,

Christoph

ps: If the answer to both questions is "no", I would be willing to work with the community and enhance the compiler if I could get some advice on how to do it best and if such a modification is wanted.