caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: John Whitington <john@coherentgraphics.co.uk>
To: "caml-list@inria.fr" <caml-list@inria.fr>
Subject: [Caml-list] Main program in C - a script
Date: Mon, 02 Dec 2013 15:26:22 +0000	[thread overview]
Message-ID: <529CA69E.8050907@coherentgraphics.co.uk> (raw)

Hi,

There has been some confusion on this topic over the years, since plenty 
of OCaml programmers aren't au fait with archive managers and linkers 
and so on. Certainly I wasn't.

Anyway, here's a script which might help:

http://github.com/johnwhitington/ocaml-main-program-in-c

On Linux / OS X it builds a static library from C and OCaml sources, 
ocamlfind packages, and ocaml libraries like unix and bigarray and then 
tests it by linking an example.

On Windows, it does the same, linking the example with flexlink. 
Additionally, it builds a DLL, and test links that with the system C linker.

Here's an example config, for building the libcpdf.(a|dll) version of my 
CPDF tools:

cfiles=(cpdflibwrapper)
finalcfile=cpdflibtest
libname=cpdf
mlfiles=(cpdflib)
mlifiles=(cpdflib)
mllibs=(unix bigarray)
ocamlfind=ocamlfind
ocamlfind_packs=(camlpdf cpdf)
stubs=(camlpdf)

Unfortunately, I've been unable to work out a way to roll ocaml 
libraries like unix and bigarray into the .a so that only a single 
linker flag -lcpdf would be needed when the .a is shipped to a customer. 
If anyone does know, do tell.

In addition, it's native code only for now. But this stuff should all be 
possible with bytecode too.

The original idea for this script was from Gerd's article here:

http://www.camlcity.org/knowledge/kb_002_shared_library.html

This is not an area of my expertise, and has only been tested on the 
sample project and libcpdf, so pull requests and bug reports are most 
welcome!

With Thanks,

-- 
John Whitington
Director, Coherent Graphics Ltd
http://www.coherentpdf.com/

             reply	other threads:[~2013-12-02 15:26 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-12-02 15:26 John Whitington [this message]
2013-12-02 15:59 ` Mykola
2013-12-03  6:03   ` Mihamina RKTMB

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=529CA69E.8050907@coherentgraphics.co.uk \
    --to=john@coherentgraphics.co.uk \
    --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;
as well as URLs for NNTP newsgroup(s).