caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* [Caml-list] toplevel with threads
@ 2002-04-13 10:35 Steve Elkins
  2002-04-14  1:59 ` Jacques Garrigue
  0 siblings, 1 reply; 4+ messages in thread
From: Steve Elkins @ 2002-04-13 10:35 UTC (permalink / raw)
  To: OCaml List

Will someone please explain what I'm doing wrong, or tell me my build
is broken, or enlighten me somehow.  I'm having trouble using threads
in toplevels, but not when I compile to bytecode.

  sge:346$ ocamlmktop -custom -o strocaml str.cma                      
  sge:347$ ./strocaml
          Objective Caml version 3.04

  # Str.regexp;;
  - : string -> Str.regexp = <fun>
  # ^D
  sge:348$ ocamlmktop -thread -custom -o throcaml threads.cma          
  Error while linking /usr/local/lib/ocaml/threads/threads.cma(ThreadUnix):
  Reference to undefined global `Unix'
  sge:349$ ocamlmktop -thread -custom -o throcaml unix.cma threads.cma
  sge:350$ ./throcaml
          Objective Caml version 3.04

  # Thread.create;;
  Unbound value Thread.create
  # ^D
  sge:351$ 

However...

  sge:351$ cat chap19.ml
  (* from p. 602 of the English translation of the O'Reilly book *)

  let f_proc1 () =
    for i = 0 to 10 do
      Printf.printf "(%d)" i;
      flush stdout
    done;
    print_newline() ;;

  let t1 = Thread.create f_proc1 () ;;

  Thread.join t1 ;;
  sge:352$ ocamlc -thread threads.cma chap19.ml                        
  sge:353$ ./a.out
  (0)(1)(2)(3)(4)(5)(6)(7)(8)(9)(10)
  sge:354$ 

I followed the instructions in the manual to build my Str toplevel,
but there are none at the beginning of the threads library section.
What am I doing wrong?

Thanks,
Steve
-------------------
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


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

* Re: [Caml-list] toplevel with threads
  2002-04-13 10:35 [Caml-list] toplevel with threads Steve Elkins
@ 2002-04-14  1:59 ` Jacques Garrigue
  2002-04-14  9:06   ` Steve Elkins
  2002-04-14 10:48   ` Markus Mottl
  0 siblings, 2 replies; 4+ messages in thread
From: Jacques Garrigue @ 2002-04-14  1:59 UTC (permalink / raw)
  To: sgelkins; +Cc: caml-list

From: Steve Elkins <sgelkins@bellsouth.net>

> Will someone please explain what I'm doing wrong, or tell me my build
> is broken, or enlighten me somehow.  I'm having trouble using threads
> in toplevels, but not when I compile to bytecode.
> 
>   sge:346$ ocamlmktop -custom -o strocaml str.cma                      

Which architecture (OS) are you working with?
Since ocaml 3.04, you don't need to build custom toplevels on
architectures where dynamic loading is supported.

$ ocaml
        Objective Caml version 3.04

# #load"str.cma";;
# Str.regexp;;
- : string -> Str.regexp = <fun>

This also works for threads, but not always:

$ ocaml -I +threads
        Objective Caml version 3.04

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

>   sge:350$ ./throcaml
>           Objective Caml version 3.04
> 
>   # Thread.create;;
>   Unbound value Thread.create

You need to add the +threads directory to your load path:
$ ./throcaml -I +threads

Cheers,

Jacques Garrigue
-------------------
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


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

* Re: [Caml-list] toplevel with threads
  2002-04-14  1:59 ` Jacques Garrigue
@ 2002-04-14  9:06   ` Steve Elkins
  2002-04-14 10:48   ` Markus Mottl
  1 sibling, 0 replies; 4+ messages in thread
From: Steve Elkins @ 2002-04-14  9:06 UTC (permalink / raw)
  To: caml-list

Jacques Garrigue <garrigue@kurims.kyoto-u.ac.jp> writes:

> Which architecture (OS) are you working with?
> Since ocaml 3.04, you don't need to build custom toplevels on
> architectures where dynamic loading is supported.

  sge:279$ uname -a
  OpenBSD d8tv0m01 3.0 GENERIC#94 i386

> $ ocaml
>         Objective Caml version 3.04
> 
> # #load"str.cma";;
> # Str.regexp;;
> - : string -> Str.regexp = <fun>

  sge:280$ ocaml
          Objective Caml version 3.04

  # #load "str.cma";;
  Cannot load required shared library: dynamic loading not supported on this platform.

> You need to add the +threads directory to your load path:
> $ ./throcaml -I +threads

  sge:281$ ./throcaml -I +threads
          Objective Caml version 3.04

  # Thread.create;;
  - : ('a -> 'b) -> 'a -> Thread.t = <fun>

Apologies, I should've tried '-I +threads', I guess not needing it
with 'ocamlc' threw me off the trail.

Thanks for the tip.

Steve
-------------------
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


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

* Re: [Caml-list] toplevel with threads
  2002-04-14  1:59 ` Jacques Garrigue
  2002-04-14  9:06   ` Steve Elkins
@ 2002-04-14 10:48   ` Markus Mottl
  1 sibling, 0 replies; 4+ messages in thread
From: Markus Mottl @ 2002-04-14 10:48 UTC (permalink / raw)
  To: Jacques Garrigue; +Cc: sgelkins, caml-list

On Sun, 14 Apr 2002, Jacques Garrigue wrote:
> This also works for threads, but not always:
> 
> $ ocaml -I +threads
>         Objective Caml version 3.04
> 
> # #load"unix.cma";;
> # #load"threads.cma";;

Btw., another way to do it, which people are often not aware of, is to
use the "directory" directive instead of passing a command line argument:

> $ ocaml
>         Objective Caml version 3.04
  # #load "unix.cma";;
  # #directory "+threads";;
  # #load "threads.cma";;

This is very useful in interpreted scripts.

Regards,
Markus Mottl

-- 
Markus Mottl                                             markus@oefai.at
Austrian Research Institute
for Artificial Intelligence                  http://www.oefai.at/~markus
-------------------
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


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

end of thread, other threads:[~2002-04-14 10:48 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-04-13 10:35 [Caml-list] toplevel with threads Steve Elkins
2002-04-14  1:59 ` Jacques Garrigue
2002-04-14  9:06   ` Steve Elkins
2002-04-14 10:48   ` Markus Mottl

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