caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: bill yan <Xue-Yang.Yan@Sun.COM>
To: Richard Jones <rich@annexia.org>
Cc: "Stéphane Glondu" <steph@glondu.net>, caml-list@inria.fr
Subject: Re: [Caml-list] What's the purpose of the static library?
Date: Thu, 25 Sep 2008 18:58:48 +0800	[thread overview]
Message-ID: <48DB6EE8.3040508@sun.com> (raw)
In-Reply-To: <20080923101710.GA29133@annexia.org>

[-- Attachment #1: Type: text/plain, Size: 4144 bytes --]

Hi Richard,

Thanks a lot for your help on this topic.  Now I have a quesiton for the 
following part:

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.



By my understanding, unlike  dlllibrary.so and liblibrary.a give user an 
option to choose compile dynamically or staticly,  it seems for 
library.a, user can only choose static method. Does that mean  "compiled 
native code" can only be staticly linked to user's application?

Thanks & Best regards,
Bill

Richard Jones ???:

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

[-- Attachment #2: Type: text/html, Size: 4574 bytes --]

  parent reply	other threads:[~2008-09-25 11:04 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
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       ` bill yan [this message]
2008-09-25 11:11         ` [Caml-list] " 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=48DB6EE8.3040508@sun.com \
    --to=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).