Mailing list for all users of the OCaml language and system.
 help / color / mirror / Atom feed
From: "Stéphane Glondu" <steph@glondu.net>
To: Tom Ridge <tom.j.ridge+caml@googlemail.com>
Cc: caml-list <caml-list@inria.fr>
Subject: Re: [Caml-list] Using OCaml from C
Date: Tue, 10 Sep 2013 15:09:23 +0200	[thread overview]
Message-ID: <522F1A03.9020001@glondu.net> (raw)
In-Reply-To: <CABooLwMEP38swFGFG5NCH-_fsR6gGbYvRPn1d5SCcGv=3Jp16w@mail.gmail.com>

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


  parent reply	other threads:[~2013-09-10 13:09 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-09-10 12:21 Tom Ridge
2013-09-10 12:41 ` David Allsopp
2013-09-10 13:21   ` Gerd Stolpmann
2013-09-10 13:09 ` Stéphane Glondu [this message]
2013-09-10 13:30   ` David Allsopp
2013-09-10 13:59     ` Tom Ridge
2013-09-10 14:21     ` Stéphane Glondu
     [not found]       ` <CABooLwPmKWc0KAOZ2weuwAfBbXUUKhBa7rxJ+=LASVL-0KeBmA@mail.gmail.com>
2013-09-10 17:21         ` Fwd: " Tom Ridge
2013-09-10 17:27           ` Adrien Nader
2013-09-12  9:51             ` Stéphane Glondu

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=522F1A03.9020001@glondu.net \
    --to=steph@glondu.net \
    --cc=caml-list@inria.fr \
    --cc=tom.j.ridge+caml@googlemail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox