Version française
Home     About     Download     Resources     Contact us    
Browse thread
Missing something in getting C and Ocaml to Work Together
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Xavier Leroy <Xavier.Leroy@i...>
Subject: Re: Missing something in getting C and Ocaml to Work Together
> 	I have a very simple application. I have the main in ocaml and 
> the rest of the system in C. I'm just trying something very straight
> forward.
> [...]
> ocamlc main.cmo -custom -cclib csrc/libmainc.a
> When I do, I get no errors but 
> ocamlrun a.out
> produces
> Fatal error: this bytecode file cannot run on this bytecode interpreter
> Mismatch on primitive `cmainarg'

Just run a.out directly, as in "./a.out".  The -custom flag to ocamlc
causes it to produce a "mixed" executable containing both OCaml
bytecode and a specially tailored bytecode interpreter that includes
your C code.

Using the standard "ocamlrun" bytecode interpreter on such an
executable fails, because ocamlrun doesn't contain the C functions that
the bytecode part of the mixed executable calls ("cmainarg" here).

Hope this helps,

- Xavier Leroy