From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail3-relais-sop.national.inria.fr (mail3-relais-sop.national.inria.fr [192.134.164.104]) by sympa.inria.fr (Postfix) with ESMTPS id 7DFB6820A1 for ; Tue, 10 Sep 2013 16:21:17 +0200 (CEST) X-IronPort-AV: E=Sophos;i="4.90,878,1371074400"; d="scan'208";a="26370040" Received: from wencory.loria.fr (HELO [152.81.3.42]) ([152.81.3.42]) by mail3-relais-sop.national.inria.fr with ESMTP; 10 Sep 2013 16:21:17 +0200 Message-ID: <522F2ADD.6010208@glondu.net> Date: Tue, 10 Sep 2013 16:21:17 +0200 From: =?ISO-8859-1?Q?St=E9phane_Glondu?= User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130821 Icedove/17.0.8 MIME-Version: 1.0 To: caml-list@inria.fr References: <522F1A03.9020001@glondu.net> In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit Subject: Re: [Caml-list] Using OCaml from C Le 10/09/2013 15:30, David Allsopp a écrit : >> Your calls to cp, ar and your use of -custom look suspicious. But it is >> difficult to be more helpful without a concrete testcase. > > They're exactly as in the manual and are correct for compiling with ocamlc for static linking with C code. The cp and ar calls are necessary to set-up the static library (which should use libcamlrun.a as a starting point) - see #19.8 (the example in question), #19.7.4, #19.7.5 and #19.1.3 in the manual. Well, that doesn't make them more right. With the example of the manual, the following works and is much saner: ocamlc -output-obj -o modcaml.o mod.ml ocamlc -c modwrap.c ar rcs mod.a modcaml.o modwrap.o cc -o prog main.c mod.a -L`ocamlc -where` -lcamlrun -lm -ldl -lcurses Copying libcamlrun.a around and fiddling with it also works and avoids -L`ocamlc -where` -lcamlrun but it is just insane, as insane as embedding the C standard library and runtime into third-party static libraries. Cheers, -- Stéphane