caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* Compiling a library with findlib
@ 2007-05-14  7:06 Sébastien Hinderer
  2007-05-14 17:37 ` [Caml-list] " Eric Cooper
  0 siblings, 1 reply; 7+ messages in thread
From: Sébastien Hinderer @ 2007-05-14  7:06 UTC (permalink / raw)
  To: caml-list

Dear all,

I am wondering what would be cleanest way of compiling a library
including C stubs using the ocamlfind program.

The library consists in the files lib.ml, lib.mli, lib_stubs.c and
constants.ml which is generated by awk scripts from C sources.

For the moment, the configure script detects wether ocamlfind is
installed or not. If it is not installed, ocamlmklib is used and
produces lib.cma, lib.cmxa, lib.a and lib.so which all seem to be
useful.

When ocamlfind is installed, though, I have no idea how to produce lib.a
and lib.so which seem to be necessary.
In particular, ocamlfind does not seem to have an interface to the
ocamlmklib connand.
So the questions I have are:

1. Is it necessary to compile/install the lib;a and lib.so files ?
2. How can these files be produced (in addition to the .cma and .cmxa
files) on a system where ocamlfindlib is installed ?

Thanks a lot for your help,
Sébastien.


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [Caml-list] Compiling a library with findlib
  2007-05-14  7:06 Compiling a library with findlib Sébastien Hinderer
@ 2007-05-14 17:37 ` Eric Cooper
  2007-05-15  9:09   ` Sébastien Hinderer
  0 siblings, 1 reply; 7+ messages in thread
From: Eric Cooper @ 2007-05-14 17:37 UTC (permalink / raw)
  To: caml-list

On Mon, May 14, 2007 at 09:06:09AM +0200, Sébastien Hinderer wrote:
> I am wondering what would be cleanest way of compiling a library
> including C stubs using the ocamlfind program.

If you use the OCamlMakefile, the "byte-code-library" and
"native-code-library" targets take care of this very painlessly.

-- 
Eric Cooper             e c c @ c m u . e d u


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Compiling a library with findlib
  2007-05-14 17:37 ` [Caml-list] " Eric Cooper
@ 2007-05-15  9:09   ` Sébastien Hinderer
  2007-05-15 10:06     ` [Caml-list] " Robert Roessler
  0 siblings, 1 reply; 7+ messages in thread
From: Sébastien Hinderer @ 2007-05-15  9:09 UTC (permalink / raw)
  To: caml-list

Hi,

Eric Cooper :
> On Mon, May 14, 2007 at 09:06:09AM +0200, Sébastien Hinderer wrote:
> > I am wondering what would be cleanest way of compiling a library
> > including C stubs using the ocamlfind program.
> 
> If you use the OCamlMakefile, the "byte-code-library" and
> "native-code-library" targets take care of this very painlessly.

As I said, I'd prefer not to use OCamlMakefile if possible... Does such
a choice look unwise to you all ?

Cheers,
Sébastien.


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [Caml-list] Re: Compiling a library with findlib
  2007-05-15  9:09   ` Sébastien Hinderer
@ 2007-05-15 10:06     ` Robert Roessler
  2007-05-15 13:04       ` Eric Cooper
  2007-05-15 13:22       ` Sébastien Hinderer
  0 siblings, 2 replies; 7+ messages in thread
From: Robert Roessler @ 2007-05-15 10:06 UTC (permalink / raw)
  To: Caml-list

Sébastien Hinderer wrote:
> ...
> As I said, I'd prefer not to use OCamlMakefile if possible... Does such
> a choice look unwise to you all ?

Not at all... but then, perhaps like you, I believe that "make" is 
perfectly adequate for most small-to-medium build tasks, and that 
truly "open" software is designed to be built with standard tools 
available in either the stock distribution of OCaml or at least easily 
found for the dominant platforms: Windows, the major *nix distros, and 
Mac OS X. ;)

Robert Roessler
roessler@rftp.com
http://www.rftp.com


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [Caml-list] Re: Compiling a library with findlib
  2007-05-15 10:06     ` [Caml-list] " Robert Roessler
@ 2007-05-15 13:04       ` Eric Cooper
  2007-05-15 13:22       ` Sébastien Hinderer
  1 sibling, 0 replies; 7+ messages in thread
From: Eric Cooper @ 2007-05-15 13:04 UTC (permalink / raw)
  To: Caml-list

On Tue, May 15, 2007 at 03:06:36AM -0700, Robert Roessler wrote:
> Sébastien Hinderer wrote:
> >...
> >As I said, I'd prefer not to use OCamlMakefile if possible... Does such
> >a choice look unwise to you all ?
> 
> Not at all... but then, perhaps like you, I believe that "make" is 
> perfectly adequate for most small-to-medium build tasks, and that 
> truly "open" software is designed to be built with standard tools 
> available in either the stock distribution of OCaml or at least easily 
> found for the dominant platforms: Windows, the major *nix distros, and 
> Mac OS X. ;)

Sorry, I must have missed the OP's objection to using OCamlMakefile.
But in any case, it's just a (big, complex) Makefile, so even if you
don't want to use it as-is, you can look at what it does, and adopt a
subset of its rules for your application.

-- 
Eric Cooper             e c c @ c m u . e d u


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Re: Compiling a library with findlib
  2007-05-15 10:06     ` [Caml-list] " Robert Roessler
  2007-05-15 13:04       ` Eric Cooper
@ 2007-05-15 13:22       ` Sébastien Hinderer
  1 sibling, 0 replies; 7+ messages in thread
From: Sébastien Hinderer @ 2007-05-15 13:22 UTC (permalink / raw)
  To: caml-list, Caml-list

Robert Roessler :
> Not at all... but then, perhaps like you, I believe that "make" is 
> perfectly adequate for most small-to-medium build tasks, and that 
> truly "open" software is designed to be built with standard tools 
> available in either the stock distribution of OCaml or at least easily 
> found for the dominant platforms: Windows, the major *nix distros, and 
> Mac OS X. ;)

Agreed.
Sébastien.


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [Caml-list] Compiling a library with findlib
       [not found] <20070514100005.459F6BC70@yquem.inria.fr>
@ 2007-05-14 10:52 ` David Allsopp
  0 siblings, 0 replies; 7+ messages in thread
From: David Allsopp @ 2007-05-14 10:52 UTC (permalink / raw)
  To: caml-list

> 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


^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2007-05-15 13:22 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-05-14  7:06 Compiling a library with findlib Sébastien Hinderer
2007-05-14 17:37 ` [Caml-list] " Eric Cooper
2007-05-15  9:09   ` Sébastien Hinderer
2007-05-15 10:06     ` [Caml-list] " Robert Roessler
2007-05-15 13:04       ` Eric Cooper
2007-05-15 13:22       ` Sébastien Hinderer
     [not found] <20070514100005.459F6BC70@yquem.inria.fr>
2007-05-14 10:52 ` [Caml-list] " David Allsopp

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