caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Alain Frisch <alain@frisch.fr>
To: Richard Jones <rich@annexia.org>
Cc: "bill yan" <Xue-Yang.Yan@Sun.COM>,
	"Stéphane Glondu" <steph@glondu.net>,
	caml-list@inria.fr
Subject: Re: [Caml-list] What's the purpose of the static library?
Date: Tue, 23 Sep 2008 13:42:45 +0200	[thread overview]
Message-ID: <48D8D635.3040705@frisch.fr> (raw)
In-Reply-To: <20080923101710.GA29133@annexia.org>

Richard Jones wrote:
> File: library.cma ------------------------------
> 
> This is just a set of *.cmo files combined together.
> 
> Created by: 'ocamlc -a'
> 
> Used: Same as for module.cmo

.cma files also contain extra linking directives like references to C 
libraries.

> 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.

... or compiling other modules.

> 
> 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.

This is true.

.cmx files are needed when they contain modules compiled with -for-pack. 
Otherwise, they are optional. Hiding them to the compiler is a way to 
get fewer dependencies (more separate compilation).

Note that the .o extension is actually .obj for the MSVC ports under 
Windows.

> 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.

(.lib for MSVC ports)

> 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.

dlllibrary.so is also used by the bytecode interpreter, by Dynlink and 
by ocamlc (to check for the availability of C primitives at compile time).


-- Alain


  reply	other threads:[~2008-09-23 11:42 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-09-22  3:36 bill yan
2008-09-22  9:35 ` [Caml-list] " Stéphane Glondu
2008-09-23  9:09   ` bill yan
2008-09-23 10:17     ` Richard Jones
2008-09-23 11:42       ` Alain Frisch [this message]
2008-09-23 12:49       ` Chris Conway
2008-09-24 11:24       ` [Caml-list] " Stefano Zacchiroli
2008-09-24 17:28         ` Richard Jones
2008-09-24 20:09       ` Sylvain Le Gall
2008-09-25 10:58       ` [Caml-list] " bill yan
2008-09-25 11:11         ` Alain Frisch
2008-10-08  3:20           ` bill yan
2008-10-08  3:29             ` bill yan
2008-09-23 10:24     ` Daniel Bünzli

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=48D8D635.3040705@frisch.fr \
    --to=alain@frisch.fr \
    --cc=Xue-Yang.Yan@Sun.COM \
    --cc=caml-list@inria.fr \
    --cc=rich@annexia.org \
    --cc=steph@glondu.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).