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