caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: "Daniel Bünzli" <daniel.buenzli@erratique.ch>
To: dbenjamin@janestreet.com
Cc: caml-list@inria.fr
Subject: Re: [Caml-list] Static linking via Ctypes?
Date: Tue, 25 Mar 2014 16:10:52 +0100	[thread overview]
Message-ID: <3744967737CD4861878DD3756D7970FD@erratique.ch> (raw)
In-Reply-To: <sympa.1395758971.27651.464@inria.fr>

Le mardi, 25 mars 2014 à 15:54, dbenjamin@janestreet.com a écrit :
> I'm using Ctypes to interface with a dynamic library, but in addition to the
> interface provided the library I have some helper functions (written in C,
> against the same library) that I'd also like to call via Ctypes. Is there any
> way to achieve this via static linking or am I required to build another
> shared object?

If you are using ctype's libffi backend you don't need in theory to build a shared dllmylib.so shared object to put in ocaml's lib/stublib. However in practice this is still useful to do even if that shared object is empty as it allows you to record the correct link flags for the dlled C library you bind to.  Doing so allows your users to simply use the ocamlfind package or #require it in the toplevel and everything works correctly, no C link flags to mess with when the binding is used.

This empty dll could be the place to put your helper functions. See this comment on how to proceed:

https://github.com/ocamllabs/ocaml-ctypes/issues/51#issuecomment-30729675

e.g. in that case you would put your helper functions in that empty tsdl_stub.c file.  

Best,

Daniel



      parent reply	other threads:[~2014-03-25 15:10 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-03-25 14:54 dbenjamin
2014-03-25 15:04 ` Bruno Deferrari
2014-03-25 15:11   ` Dan Benjamin
2014-03-25 15:24     ` David Sheets
2014-03-25 17:55       ` Dan Benjamin
2014-03-25 21:19         ` Jeremy Yallop
2014-03-25 21:37           ` Milan Stanojević
2014-03-25 23:14             ` Jeremy Yallop
2014-03-26 16:24               ` Travis Brady
2014-03-26 17:17                 ` Daniel Bünzli
2014-03-26 17:25               ` Milan Stanojević
2014-03-25 15:10 ` Daniel Bünzli [this message]

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=3744967737CD4861878DD3756D7970FD@erratique.ch \
    --to=daniel.buenzli@erratique.ch \
    --cc=caml-list@inria.fr \
    --cc=dbenjamin@janestreet.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;
as well as URLs for NNTP newsgroup(s).