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=AWL autolearn=disabled version=3.1.3 X-Original-To: caml-list@yquem.inria.fr Delivered-To: caml-list@yquem.inria.fr Received: from mail3-relais-sop.national.inria.fr (mail3-relais-sop.national.inria.fr [192.134.164.104]) by yquem.inria.fr (Postfix) with ESMTP id BE412BB84 for ; Tue, 23 Sep 2008 12:17:16 +0200 (CEST) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AtEDAMBe2EhQRFuwiGdsb2JhbACTHwEBARUio16BZg X-IronPort-AV: E=Sophos;i="4.32,451,1217800800"; d="scan'208";a="17254134" Received: from discorde.inria.fr ([192.93.2.38]) by mail3-smtp-sop.national.inria.fr with ESMTP; 23 Sep 2008 12:17:16 +0200 Received: from mail3-relais-sop.national.inria.fr (mail3-relais-sop.national.inria.fr [192.134.164.104]) by discorde.inria.fr (8.13.6/8.13.6) with ESMTP id m8NAHFIi000605 (version=TLSv1/SSLv3 cipher=RC4-SHA bits=128 verify=OK) for ; Tue, 23 Sep 2008 12:17:16 +0200 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AtEDAMBe2EhQRFuwiGdsb2JhbACTHwEBARUio16BZg X-IronPort-AV: E=Sophos;i="4.32,451,1217800800"; d="scan'208";a="17254133" Received: from furbychan.cocan.org ([80.68.91.176]) by mail3-smtp-sop.national.inria.fr with ESMTP/TLS/AES256-SHA; 23 Sep 2008 12:17:15 +0200 Received: from rich by furbychan.cocan.org with local (Exim 4.63) (envelope-from ) id 1Ki4xD-00083l-7J; Tue, 23 Sep 2008 11:17:11 +0100 Date: Tue, 23 Sep 2008 11:17:11 +0100 To: bill yan Cc: =?iso-8859-1?Q?St=E9phane?= Glondu , caml-list@inria.fr Subject: Re: [Caml-list] What's the purpose of the static library? Message-ID: <20080923101710.GA29133@annexia.org> References: <48D712A8.6090506@sun.com> <48D766CC.5020401@glondu.net> <48D8B266.4000906@sun.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <48D8B266.4000906@sun.com> User-Agent: Mutt/1.5.13 (2006-08-11) From: Richard Jones X-Miltered: at discorde with ID 48D8C22C.000 by Joe's j-chkmail (http://j-chkmail . ensmp . fr)! X-Spam: no; 0.00; ocaml:01 cmi:01 mli:01 compiler:01 'ocamlc:01 mli:01 'ocamlc:01 ml':01 ml':01 toplevel:01 compiler:01 foo:01 cmo:01 bytecode:01 bytecode:01 On Tue, Sep 23, 2008 at 05:09:58PM +0800, bill yan wrote: > Thanks a lot for your information. And we'd like to know more about the > OCaml library architectures, like on what situation dynamic libraries > are used, and when static libraries are used, and so on.. Really > appreciate if you could point me to a document that can help on this topic. It's not particularly well-documented, and it changes a little in 3.11, but below is my understanding. There are probably errors in what follows. If someone can correct the errors then I'll publish a corrected document. File: module.cmi ------------------------------ Contains the compiled interface for Module, essentially equivalent to the contents of the *.mli file but in a compiled/binary form which the compiler can load easily. Created by: 'ocamlc -c module.mli', or if module.mli doesn't exist then 'ocamlc -c module.ml' (also by 'ocamlopt -c module.ml'). Used: Whenever the toplevel or compiler uses any symbol Module.foo, this file is consulted. File: module.cmo ------------------------------ Contains the bytecode of the implementation of Module. Created by: 'ocamlc -c module.ml' Used: When linking bytecode programs, or creating bytecode libraries (*.cma), or by the toplevel when you use #load, or by Dynlink. File: library.cma ------------------------------ This is just a set of *.cmo files combined together. Created by: 'ocamlc -a' Used: Same as for module.cmo Files: module.o and module.cmx -------------------- These two files go together. The *.o file contains compiled native code in the normal system object file format. The *.cmx file contains metainformation about the machine code in the *.o file. Created by: 'ocamlopt -c module.ml' Used: When linking native code programs, or creating native code libraries. Note(1): You normally never need to specify the *.o files by hand. On the command line when the compiler sees a *.cmx file, it looks for the corresponding *.o file if it needs it. Note(2): It is thought that the *.cmx file needs to be around even when linking a library (*.cmxa) file in order to do cross-module function inlining. Both the Debian & Fedora packaging rules specify that *.cmx files be kept around for this reason. Whether this is really true or not is not certain. File: library.a and library.cmxa -------------------- These files go together. The *.a file contains compiled native code in the normal system archive format. The *.cmxa file contains metainformation. Created by: 'ocamlopt -a' Used: Same as for *.o/*.cmx Note: You normally never need to specify the *.a files by hand. File: dlllibrary.so and liblibrary.a -------------------- These files are created and used when a bytecode or native library contains some C code. 'dllXXX.so' is created for use by the toplevel and contains the compiled C code. 'libXXX.a' is created for use by compiled standalone programs and also contains the same compiled C code. Created by: 'ocamlmklib -o library *.o *.cmo' or: 'ocamlmklib -o library *.o *.cmx' Used: dlllibrary.so is dlopen(2)'d by the toplevel. liblibrary.a is linked in standalone programs. Note: You normally never need to specify these files by hand. The *.cma/*.cmxa file contains the necessary information to find these files if necessary. ---------------------------------------------------------------------- Rich. -- Richard Jones Red Hat