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 mail2-relais-roc.national.inria.fr (mail2-relais-roc.national.inria.fr [192.134.164.83]) by sympa.inria.fr (Postfix) with ESMTPS id 7717D820A1 for ; Thu, 22 Aug 2013 19:34:42 +0200 (CEST) Received-SPF: None (mail2-smtp-roc.national.inria.fr: no sender authenticity information available from domain of john@coherentgraphics.co.uk) identity=pra; client-ip=188.64.184.40; receiver=mail2-smtp-roc.national.inria.fr; envelope-from="john@coherentgraphics.co.uk"; x-sender="john@coherentgraphics.co.uk"; x-conformance=sidf_compatible Received-SPF: None (mail2-smtp-roc.national.inria.fr: no sender authenticity information available from domain of john@coherentgraphics.co.uk) identity=mailfrom; client-ip=188.64.184.40; receiver=mail2-smtp-roc.national.inria.fr; envelope-from="john@coherentgraphics.co.uk"; x-sender="john@coherentgraphics.co.uk"; x-conformance=sidf_compatible Received-SPF: None (mail2-smtp-roc.national.inria.fr: no sender authenticity information available from domain of postmaster@bluechip4.ukhost4u.com) identity=helo; client-ip=188.64.184.40; receiver=mail2-smtp-roc.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: ApQCAKFKFlK8QLgoemdsb2JhbABagzzBdhYOAQELBxY8gmNAIxoTAxgDAgECAUuIJ5U7oUGVAwOZE5NN X-IPAS-Result: ApQCAKFKFlK8QLgoemdsb2JhbABagzzBdhYOAQELBxY8gmNAIxoTAxgDAgECAUuIJ5U7oUGVAwOZE5NN X-IronPort-AV: E=Sophos;i="4.89,935,1367964000"; d="scan'208";a="30094133" Received: from bluechip4.ukhost4u.com ([188.64.184.40]) by mail2-smtp-roc.national.inria.fr with ESMTP/TLS/DHE-RSA-AES256-SHA; 22 Aug 2013 19:34:41 +0200 Received: from 78-105-203-81.zone3.bethere.co.uk ([78.105.203.81]:54958 helo=feast.local) by bluechip4.ukhost4u.com with esmtpa (Exim 4.80.1) (envelope-from ) id 1VCYmO-002N0n-Of for caml-list@inria.fr; Thu, 22 Aug 2013 18:34:40 +0100 Message-ID: <52164BAE.3080509@coherentgraphics.co.uk> Date: Thu, 22 Aug 2013 18:34:38 +0100 From: John Whitington User-Agent: Postbox 3.0.8 (Macintosh/20130427) MIME-Version: 1.0 To: caml users 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] Building a mixed C / OCaml static library to be used from C Hi, I have the following recipe to build a static library of C functions from a mixed ocaml / c codebase. The idea is that the final linking step to build target 'test' won't require any special flags: CAMLBASE = /Users/john/.opam/4.00.1/lib/ mklib: cpdflib.mli cpdflib.ml cpdflibwrapper.c ocamlfind ocamlc -package cpdf cpdflib.mli; ocamlfind ocamlopt -package cpdf -c cpdflib.ml; ocamlfind ocamlc cpdflibwrapper.c; ocamlfind ocamlopt -I $(CAMLBASE)cpdf -I $(CAMLBASE)camlpdf \ -output-obj -o cpdflib.o \ unix.cmxa bigarray.cmxa camlpdf.cmxa cpdf.cmxa cpdflib.cmx; ar -x $(CAMLBASE)camlpdf/libcamlpdf_stubs.a; ar -x $(CAMLBASE)ocaml/libasmrun.a; ar cr cpdflib.a *.o test: cpdflib.a cpdflibtest.c cc cpdflibtest.c cpdflib.a -o test\ -L $(CAMLBASE)ocaml -lbigarray -lunix clean: rm __.SYMDEF\ SORTED *.o *.cmx *.cmi *.a test (Here, cpdflib.ml, cpdflib.mli and cpdflibwrapper.c form the C interface to the OCaml functions. cpdflibtest.c calls caml_startup and then any caml functions it likes). This works. However, I'm having trouble getting rid of "-L $(CAMLBASE)ocaml -lbigarray -lunix" -- i'd like the person linking with my cpdflib.a not to need any dependencies at all. When I add two more lines ar -x $(CAMLBASE)ocaml/bigarray.a; ar -x $(CAMLBASE)ocaml/unix.a; in the obvious place and remove "-L $(CAMLBASE)ocaml -lbigarray -lunix" when building the example, the linking fails, not being able to find the symbols for unix and bigarray. ar -t confirms that bigarray.o, unix.o and unixlabels.o are in the created cpdflib.a Any ideas, or another recipe altogether? Thanks, -- John Whitington Director, Coherent Graphics Ltd http://www.coherentpdf.com/