From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail1-relais-roc.national.inria.fr (mail1-relais-roc.national.inria.fr [192.134.164.82]) by walapai.inria.fr (8.13.6/8.13.6) with ESMTP id p55AJcEP008425 for ; Sun, 5 Jun 2011 12:19:38 +0200 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AtUPAPVX601V2gB4VWdsb2JhbABTmByOKQEWCAwGFyWoY517DoYTBJVeilc X-IronPort-AV: E=Sophos;i="4.65,322,1304287200"; d="scan'208";a="110265162" Received: from emailfrontal1.citycable.ch ([85.218.0.120]) by mail1-smtp-roc.national.inria.fr with SMTP; 05 Jun 2011 12:19:17 +0200 X-Alinto-smtpauth-localdomain: Yes Received: from seldon (unknown [85.218.93.111]) (Authenticated sender: guillaume.yziquel@citycable.ch) by emailfrontal1.citycable.ch (Postfix) with ESMTPA id B6D6AB694CD; Sun, 5 Jun 2011 12:19:03 +0200 (CEST) Received: from yziquel by seldon with local (Exim 4.72) (envelope-from ) id 1QTAPH-0001jB-Jw; Sun, 05 Jun 2011 12:18:07 +0200 Date: Sun, 5 Jun 2011 12:18:07 +0200 From: Guillaume Yziquel To: caml-list@yquem.inria.fr Message-ID: <20110605101807.GB22132@localhost> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.5.20 (2009-06-14) Subject: [Caml-list] findlib and ocamlopt -output-obj Hi. I'm currently writing mixed code in OCaml and Mercury. This means that I need to initialise Mercury by a call to mercury_init() following guidelines in http://www.mercury.csse.unimelb.edu.au/information/doc-release/mercury_user_guide/Stand_002dalone-Interfaces.html#Stand_002dalone-Interfaces This requires to pass an address (i.e. stackbottom) to mercury_init that informs Boehm's GC of where it should begin tracing. So essentially, you need to start OCaml from a C main() and have stackbottom allocated on main()'s stack frame. Something like: yziquel@seldon:~$ cat mercury_init.c value mercury_stackbottom; int main (int argc, char ** argv) { void * stackbottom; // Word aligned mercury_stackbottom = (value) &stackbottom; caml_startup (argv); return 0; } mercury_init() then gets called as a C stub from OCaml code, and the C stub uses the mercury_stackbottom global. However, to generate an executable out of all that, I need to link in quite a lot of findlib dependencies. I'm currently doing it explicitely by calling ocamlopt with all the dependencies manually, but I failed to manage to use ocamlfind together with the -output-obj command line option to pull in the dependencies. Anyone knows how to do that? -- Guillaume Yziquel