From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.1.3 (2006-06-01) on yquem.inria.fr X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=none autolearn=disabled version=3.1.3 X-Original-To: caml-list@yquem.inria.fr Delivered-To: caml-list@yquem.inria.fr Received: from concorde.inria.fr (concorde.inria.fr [192.93.2.39]) by yquem.inria.fr (Postfix) with ESMTP id 867B4BC0A for ; Mon, 14 May 2007 12:52:07 +0200 (CEST) Received: from orion.metastack.com (no-dns-yet.demon.co.uk [80.177.38.218] (may be forged)) by concorde.inria.fr (8.13.6/8.13.6) with ESMTP id l4EAq677027029 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=FAIL) for ; Mon, 14 May 2007 12:52:07 +0200 Received: from treble (cpc2-cmbg6-0-0-cust535.cmbg.cable.ntl.com [81.107.34.24]) (authenticated bits=0) by orion.metastack.com (8.13.4/8.13.3) with ESMTP id l4EApAOA026005 (version=TLSv1/SSLv3 cipher=RC4-MD5 bits=128 verify=NO) for ; Mon, 14 May 2007 11:51:12 +0100 From: "David Allsopp" To: References: <20070514100005.459F6BC70@yquem.inria.fr> Subject: Re: [Caml-list] Compiling a library with findlib Date: Mon, 14 May 2007 11:52:07 +0100 Organization: MetaStack Solutions Ltd. Message-ID: <002d01c79615$ea3d3d30$6a7ba8c0@treble> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-Mailer: Microsoft Office Outlook 11 Thread-Index: AceWDpjDSFglzDWLQFCsYyEnZzow2wAArclA X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.3028 In-Reply-To: <20070514100005.459F6BC70@yquem.inria.fr> X-Miltered: at concorde with ID 46483F56.004 by Joe's j-chkmail (http://j-chkmail . ensmp . fr)! X-Spam: no; 0.00; findlib:01 lib:01 lib:01 bytecode:01 stub:01 cmo:01 stub:01 ocamlopt:01 cmxa:01 makefiles:01 ocamlmklib:01 ocamlmklib:01 -verbose:01 ocamlc:01 ocamlopt:01 > 1. Is it necessary to compile/install the lib;a and lib.so files ? Yes they are both needed: lib.so is the bytecode stub library --- so needed for any .cmo file that uses the C module lib.a is the native stub library --- linked in when you compile with ocamlopt for the same purpose > 2. How can these files be produced (in addition to the .cma and .cmxa > files) on a system where ocamlfindlib is installed ? I'm a Windows native port user so detest Makefiles that use ocamlmklib because the Windows port doesn't include it! The automation provided by ocamlmklib is IMHO pretty simplistic (see #18.10 in the manual). ocamlmklib -verbose will tell you the commands it uses for your project - all the ocamlc/ocamlopt commands can then be prefixed with ocamlfind to import any packages you may need. When doing ocamlfind install, you just need to include lib.so and lib.a with the files (r17.html#OCAMLFIND.INSTALL of the findlib docs explains how stub libraries are dealt with). HTH, David ---------- Here's a snippet from the Makefile I use for doing this under Windows for a library with a lot of stubs (with some omitted variables for clarity). NB I prefer to call gcc directly - but ocamlc can of course call gcc for you. libMSLStdLib.a: $(O_FILES) ar rsc $@ $(O_FILES) dllMSLStdLib.dll: $(O_FILES) gcc -mno-cygwin -mms-bitfields -shared -I $(OCAMLLIB) -L $(OCAMLLIB) -o $@ $(O_FILES) -locamlrun MSLStdLib.cma: $(CMI_FILES) $(CMO_FILES) dllMSLStdLib.dll ocamlfind ocamlc $(PACKAGES) -a -o $@ $(CMO_FILES) -dllib -lMSLStdLib MSLStdLib.cmxa: $(CMI_FILES) $(CMX_FILES) libMSLStdLib.a ocamlfind ocamlopt $(PACKAGES) -a -o $@ $(CMX_FILES) -cclib -lMSLStdLib install: MSLStdLib.cma MSLStdLib.cmxa $(CMI_FILES) $(CMX_FILES) META dllMSLStdLib.dll libMSLStdLib.a ocamlfind install MSLStdLib META MSLStdLib.cma MSLStdLib.cmxa MSLStdLib.a libMSLStdLib.a $(CMI_FILES) $(CMX_FILES) dllMSLStdLib.dll %.o: %.c gcc -O -Wall -Wno-unused -mms-bitfields -mno-cygwin -I $(OCAMLLIB) -c $*.c