English version
Accueil     À propos     Téléchargement     Ressources     Contactez-nous    

Ce site est rarement mis à jour. Pour les informations les plus récentes, rendez-vous sur le nouveau site OCaml à l'adresse ocaml.org.

Browse thread
Threads library
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 2004-11-22 (22:18)
From: John Prevost <j.prevost@g...>
Subject: Re: [Caml-list] Threads library
On Mon, 22 Nov 2004 16:20:31 -0500 (EST), Ernesto Posse
<eposse@cs.mcgill.ca> wrote:
>   Hi. I have a problem with the threads library. Basically I am unable to
> access the library.
>   The libraries are installed in the default location
> (/usr/local/lib/ocaml) (I installed version 3.08.1, on linux
> 2.6.4-54.5-smp on i686, running SuSE)

There are two things that will help you here.  The first is that you
want to run your toplevel like this:

ocaml -I +threads

in order to make sure that the threading libraries (and more
importantly, the thread interfaces!) are on the ocaml include path. 
This is *the* most important point, since when you try to refer to the
Threads module, the toplevel is going to look in its path to find the
.mli files, regardless of what has been linked in.

The second thing is that the order in which you #load is relevant.  If you do:

#load "threads.cma";;
#load "unix.cma";;

threads isn't actually loaded--it failed to load.  I suspect you
figured that part out, however.

So, if you just do the -I +threads and then #load "threads.cma"
instead of #load ".../lib/ocaml/threads.cma", you'll succeed for the
normal toplevel.  And with the custom toplevel, you'll still need to
include -I +threads.  You can also use:

#directory "+threads";;

to add to the include path of a running ocaml process.

And as a final note, if you have installed findlib, you can either
make a toplevel with topfind compiled in, or:

#use "topfind";;

in order to get the findlib toplevel extensions.  This will let you do:


to enable threading.  (It adds +threads to the include path, then
loads unix and threads.)

Hope this helps!