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 EF281820A1 for ; Tue, 10 Sep 2013 15:09:23 +0200 (CEST) X-IronPort-AV: E=Sophos;i="4.90,878,1371074400"; d="scan'208";a="26358748" 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 15:09:23 +0200 Message-ID: <522F1A03.9020001@glondu.net> Date: Tue, 10 Sep 2013 15:09:23 +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: Tom Ridge CC: caml-list References: 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 14:21, Tom Ridge a écrit : > /home/tr61/.opam/4.00.1/lib/core/libcore_stubs.a(unix_stubs.o): In > function `unix_clock_gettime': > unix_stubs.c:(.text+0x2776): undefined reference to `clock_gettime' > > I had -lrt after -lpthread, but the error was still reported; when I > moved -lrt to end of command line things seemed to work; why? The order of -l options matters, and a library must be put *after* objects that use its symbols. System linkers have not always been strict on the ordering, but they started a few years ago. Note that this is usually the opposite of the order of OCaml objects. In your case, clock_gettime is provided by -lrt, so -lrt must be after -lcore_stubs. > /home/tr61/.opam/4.00.1/lib/core/libcore_stubs.a(unix_stubs.o): In > function `unix_initgroups': > unix_stubs.c:(.text+0x3b90): multiple definition of `unix_initgroups' > /home/tr61/.opam/4.00.1/lib/ocaml/libunix.a(initgroups.o):initgroups.c:(.text+0x0): > first defined here > /home/tr61/.opam/4.00.1/lib/core/libcore_stubs.a(unix_stubs.o): In > function `unix_nice': > unix_stubs.c:(.text+0x46bc): multiple definition of `unix_nice' > /home/tr61/.opam/4.00.1/lib/ocaml/libunix.a(nice.o):nice.c:(.text+0x0): > first defined here > > fixed by adding -Xlinker --allow-multiple-definition to cc options Is -lunix really needed here? If so, I'd rather put it after -lcore_stubs. Anyway, this doesn't look right and I would blame Core here for using the same names as the standard Unix stubs. > My real question is: what command *should* I be using to compile my > example? Or is the above more-or-less expected? Your calls to cp, ar and your use of -custom look suspicious. But it is difficult to be more helpful without a concrete testcase. Cheers, -- Stéphane