Version française
Home     About     Download     Resources     Contact us    
Browse thread
[Caml-list] Portability of Byte-Code programs
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Sven Luther <luther@d...>
Subject: Re: [Caml-list] Portability of Byte-Code programs
On Tue, Feb 11, 2003 at 07:37:01AM +0100, Oliver Bandel wrote:
> Hello,
> 
> when I create a program with ocamlc
> and give it to other people, who want
> to use it - will they be able to run
> it on another computer, even if they
> do not have the necessary libraries?
> 
> Or do they have to install them?
> 
> So, the questions goes into the direction
> of linkage - dynamic or static.
> 
> Both has advantages. For portability I
> would choose the way, to include all necessary
> libs, and for filesize-issues I would
> prefer a dynamic solution.
> 
> How does Ocaml do it?
> Or are both ways possible?

Yes, both are possible. By default ocaml links dynamically, and you need
to use the -custom flag to link statically. There is a discution of this
in the manual, i think it is in the linking with C part.

But notice that this only applies to C libraries, or bindings, the pure
caml libraries are always linked statically. When you link statically
the C bindings using the -custom flag, then you create and architecture
dependant binary, which will only run on the same architecture and
plateform than you compiled it for. On the other side, the binary is
mostly self included. When you link a binary dynamically, you need to
have the correct stublibs installed on the machine running it, in
addition to ocamlrun that is. But you alos produce a true architecture
independent bytecode executable, that is, you should be able to run on
your program equallye under windows, macosX, solaris, or whatever, even
if you compiled it under linux. The catch here is that the stublibs your
program use need to be installed on the box where it runs, and
naturally that ocaml is installed on it also, and that ocamlrun is the
same version that the one you compiled it with.

On a debian box, this is no problem, since all ocaml libraries are
separated into the developpment files, and a smallish runtime package
containing only the stublibs. In the same way, the ocaml package is
separated into the developpment package and a small package containing
only ocamlrun and the stublibs included into the ocaml package. So you
would just need to install the needed runtime packages on the box you
wish to run your program (lablgl and lablgtk for example) and you would
do this with a simple apt-get invocation.

BTW, Xavier, would it make sense to change the installation process so
that ocamlrun is no more installed as /usr/bin/ocamlrun, but as
/usr/bin/ocamlrun-version ? So that you could still run a bytecode
binary even if you have installed a newer version of ocaml on your box ?

Friendly,

Sven Luther
> 
> Ciao,
>    Oliver
> -------------------
> To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
> Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
> Beginner's list: http://groups.yahoo.com/group/ocaml_beginners
-------------------
To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners