Version française
Home     About     Download     Resources     Contact us    
Browse thread
Re: [Caml-list] Compiling a library with findlib
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: David Allsopp <dra-news@m...>
Subject: Re: [Caml-list] Compiling a library with findlib
> 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