Version française
Home     About     Download     Resources     Contact us    
Browse thread
ocamlopt and *using* DLLs
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Jacques Garrigue <garrigue@m...>
Subject: Re: [Caml-list] ocamlopt and *using* DLLs
From: Robert Roessler <roessler@rftp.com>

> I tried this on the beginners list, but may not have been asking the 
> right question(s)... :)

Doesn't look like a beginner question...

> 1) Can DLLs appear as input to the ocamlopt compiler like they can 
> with ocamlc?  The manual says "yes": "Arguments ending in .o, .a or 
> .so (.obj, .lib and .dll under Windows) are assumed to be C object 
> files and libraries. They are linked with the program."
> 
> I get "ocamlopt.opt: don't know what to do with ml_scintilla.dll."

Indeed, looking at the sources, .so/.dll is only handled in ocamlc,
not in ocamlopt.
That means that, in ocamlopt, you must either provide a static
library, or use the -cclib option and hope that the system linker does
the right thing. In practice, -cclib ml_scintilla.so should work on
Unix, but the .dll equivalent is not going to work on Windows, as the
linker does not support it.

> 2) If DLLs can in fact be used with ocamlopt, is the model the same as 
> with ocamlc?  In particular,
> 
> 2a) can I use them *without* stub libraries?

If by stub you mean the ml_scintilla.lib that the windows librarian
builds for you, then you will need it with ocamlopt (but not with
ocamlc).
Of course in both cases you also need an ocaml specific stub library
to wrap calls.

> 2b) can I in general expect that an app that works well with ocamlc 
> and a collection of OCaml cma libs and compiled DLLs (LablGTK and 
> associated runtime) will work with ocamlopt - assuming that I generate 
> and replace cmo/cma files with cmx/cmxa files?

Except these linking problems, you can assume identical behaviour.
If there are significant discrepancies, please report them.

Jacques Garrigue