From: Dawid Toton <d0@wp.pl>
To: caml-list@inria.fr
Subject: [Caml-list] Re: OCaml binary formats -- how are they linked?
Date: Fri, 14 Jun 2013 12:16:58 +0200 [thread overview]
Message-ID: <kpeqik$jb$1@ger.gmane.org> (raw)
In-Reply-To: <CAMQQO3n6mtrOAXkn9P=xZehkXo29Y8cVxHVzWNMQYeUwQ0h_oA@mail.gmail.com>
On 06/14/2013 11:30 AM, Ömer Sinan Ağacan wrote:
> Hi all,
>
> Let's say I have a C API called from OCaml. Bindings are compiled
> to .cma, .cmx, .cmxa files.
>
> What I'm wondering is that are those C objects linked to those
> binary files statically or dynamically?
>
Depending on what you do, some objects can be dynamically linked to an
OCaml program.
Since OCaml←→C interface requires the C code to follow the rules and
use the provided headers (like mlvalues.h), in practice an extra layer
of code is usually added:
---- normal OCaml stuff:
a.ml → a.cmx + a.o
---- OCaml modules with "external" functions
b.ml → b.cmx + b.o
---- the extra layer of C code:
wrappers.c → wrappers.o
---- the actural C code that doesn't care about special OCaml needs:
foo.c → foo.o
----
The OCaml compiler includes b.o and every other compiled OCaml module
in the executable.
wrappers.o and foo.o can end up as a part of dynamically linked
library, but you have choice. You can even call the linker directly
and play weird things with all the *.o files that C and OCaml
compilers produce.
Dawid
next prev parent reply other threads:[~2013-06-14 10:55 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-06-14 9:30 [Caml-list] " Ömer Sinan Ağacan
2013-06-14 10:16 ` Dawid Toton [this message]
2013-06-14 12:02 ` [Caml-list] " Ömer Sinan Ağacan
2013-06-14 14:26 ` Dawid Toton
2013-06-14 19:17 ` Ömer Sinan Ağacan
2013-06-17 0:18 ` Philippe Wang
2013-06-17 12:12 ` Ömer Sinan Ağacan
2013-06-17 12:34 ` Philippe Wang
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='kpeqik$jb$1@ger.gmane.org' \
--to=d0@wp.pl \
--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