Mailing list for all users of the OCaml language and system.
 help / color / mirror / Atom feed
From: "Stéphane Glondu" <steph@glondu.net>
To: caml-list@inria.fr
Subject: Re: [Caml-list] Using OCaml from C
Date: Tue, 10 Sep 2013 16:21:17 +0200	[thread overview]
Message-ID: <522F2ADD.6010208@glondu.net> (raw)
In-Reply-To: <E51C5B015DBD1348A1D85763337FB6D9CCB9CF15@Remus.metastack.local>

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

  parent reply	other threads:[~2013-09-10 14:21 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
2013-09-10 13:30   ` David Allsopp
2013-09-10 13:59     ` Tom Ridge
2013-09-10 14:21     ` Stéphane Glondu [this message]
     [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=522F2ADD.6010208@glondu.net \
    --to=steph@glondu.net \
    --cc=caml-list@inria.fr \
    /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