From : John Whitington <john AT coherentgraphics.co.uk>

: John Whitington <john AT coherentgraphics.co.uk> To : "caml-list AT inria.fr" <caml-list AT inria.fr>

: "caml-list AT inria.fr" <caml-list AT inria.fr> Subject : [Caml-list] Main program in C - a script

: [Caml-list] Main program in C - a script Date: Mon, 02 Dec 2013 15:26:22 +0000

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: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=cpdflibtestlibname=cpdfmlfiles=(cpdflib)mlifiles=(cpdflib)mllibs=(unix bigarray)ocamlfind=ocamlfindocamlfind_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: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 WhitingtonDirector, Coherent Graphics Ltd