From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Original-To: caml-list@sympa.inria.fr Delivered-To: caml-list@sympa.inria.fr Received: from mail3-relais-sop.national.inria.fr (mail3-relais-sop.national.inria.fr [192.134.164.104]) by sympa.inria.fr (Postfix) with ESMTPS id 6599F7EE6B for ; Mon, 2 Dec 2013 16:26:24 +0100 (CET) Received-SPF: None (mail3-smtp-sop.national.inria.fr: no sender authenticity information available from domain of john@coherentgraphics.co.uk) identity=pra; client-ip=188.64.184.40; receiver=mail3-smtp-sop.national.inria.fr; envelope-from="john@coherentgraphics.co.uk"; x-sender="john@coherentgraphics.co.uk"; x-conformance=sidf_compatible Received-SPF: None (mail3-smtp-sop.national.inria.fr: no sender authenticity information available from domain of john@coherentgraphics.co.uk) identity=mailfrom; client-ip=188.64.184.40; receiver=mail3-smtp-sop.national.inria.fr; envelope-from="john@coherentgraphics.co.uk"; x-sender="john@coherentgraphics.co.uk"; x-conformance=sidf_compatible Received-SPF: None (mail3-smtp-sop.national.inria.fr: no sender authenticity information available from domain of postmaster@bluechip4.ukhost4u.com) identity=helo; client-ip=188.64.184.40; receiver=mail3-smtp-sop.national.inria.fr; envelope-from="john@coherentgraphics.co.uk"; x-sender="postmaster@bluechip4.ukhost4u.com"; x-conformance=sidf_compatible X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: Am0DAAymnFK8QLgohGdsb2JhbABZgz+6WxYOAQEBCgcECQkUIQeCZDMNIxoWGAMCAQIBSxyHfAEIoGqea5NCA5lEhRWOdw X-IPAS-Result: Am0DAAymnFK8QLgohGdsb2JhbABZgz+6WxYOAQEBCgcECQkUIQeCZDMNIxoWGAMCAQIBSxyHfAEIoGqea5NCA5lEhRWOdw X-IronPort-AV: E=Sophos;i="4.93,811,1378850400"; d="scan'208";a="38943987" Received: from bluechip4.ukhost4u.com ([188.64.184.40]) by mail3-smtp-sop.national.inria.fr with ESMTP/TLS/DHE-RSA-AES256-SHA; 02 Dec 2013 16:26:23 +0100 Received: from [78.105.203.81] (port=63477 helo=[192.168.1.150]) by bluechip4.ukhost4u.com with esmtpsa (TLSv1:DHE-RSA-CAMELLIA256-SHA:256) (Exim 4.80.1) (envelope-from ) id 1VnVOB-002aGK-4S for caml-list@inria.fr; Mon, 02 Dec 2013 15:26:23 +0000 Message-ID: <529CA69E.8050907@coherentgraphics.co.uk> Date: Mon, 02 Dec 2013 15:26:22 +0000 From: John Whitington User-Agent: Postbox 3.0.8 (Macintosh/20130427) MIME-Version: 1.0 To: "caml-list@inria.fr" Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - bluechip4.ukhost4u.com X-AntiAbuse: Original Domain - inria.fr X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - coherentgraphics.co.uk X-Get-Message-Sender-Via: bluechip4.ukhost4u.com: authenticated_id: john@coherentgraphics.co.uk Subject: [Caml-list] Main program in C - a script 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/