English version
Accueil     À propos     Téléchargement     Ressources     Contactez-nous    

Ce site est rarement mis à jour. Pour les informations les plus récentes, rendez-vous sur le nouveau site OCaml à l'adresse ocaml.org.

Browse thread
calling OCaml from C on non-Mac platforms?
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 2009-11-15 (14:55)
From: Eric Cooper <ecc@c...>
Subject: Re: [Caml-list] calling OCaml from C on non-Mac platforms?
On Sun, Nov 15, 2009 at 08:27:49AM -0500, John Nowak wrote:
> I'm trying to call OCaml from C.
> [...] 
>    ocamlopt -output-obj hello.cmx -o hello.o

This is the main problem.  You're clobbering the hello.o that OCaml
produced when compiling hello.ml into native code.

> Does anyone have a correct set of instructions for doing this on
> non-Mac platforms? Thanks.

This worked fine for me:

  ocamlopt -output-obj -o temp.o hello.ml
  gcc -o hello main.c temp.o -L/usr/lib/ocaml -lasmrun -lm -ldl