Loading ...
Sorry, an error occurred while loading the content.

Re: "ocaml_beginners"::[] Proper compiling and threads

Expand Messages
  • Chantal Keller
    Hello Jeff, ... Just remove [#load ...] and compile with: ocamlc -o myprog unix.cma myfile.ml ocamlopt -o myprog unix.cmxa myfile.ml A nice way to compile
    Message 1 of 3 , May 6, 2011
    • 0 Attachment
      Hello Jeff,

      Le 06/05/2011 17:23, Jeff Massung a écrit :
      > 1. How can I properly write my source file so that it can #load and compile
      > without having to go back and forth editing my source file? For example:
      >
      > #load "unix.cma" ;;
      > open Unix
      > ...
      >
      > The above is perfect for the interpreter, but fails miserably when I try and
      > compile. Similarly, I assume that if I tried to compile with ocamlopt
      > instead of ocamlc that I'd need "unix.cmx" instead?

      Just remove [#load ...] and compile with:

      ocamlc -o myprog unix.cma myfile.ml
      ocamlopt -o myprog unix.cmxa myfile.ml

      A nice way to compile OCaml programs without taking much care of such
      things is to use OMake <http://omake.metaprl.org/index.html>.
      --
      Chantal KELLER
    • Philippe
      You could put your #load and open statements in a .ocamlinit file : this file, if present is read by the toplevel. Additionally you can put a #use source.ml
      Message 2 of 3 , May 6, 2011
      • 0 Attachment
        You could put your #load and open statements in a .ocamlinit file :
        this file, if present is read by the toplevel. Additionally you can
        put a #use "source.ml" in this file, to load your source as well. If
        you intend to use the toplevel, you should consider rlwrap, which
        makes it so much comfortable.

        For threads, have you tried

        #load "threads.cma"
        open Thread

        ?
        Maybe you need a
        #directory "+threads" before this ?

        I cannot check right now. Otherwise you could build a custom toplevel.
        It is very easy with ocamlbuid.

        Ph.



        Le 6 mai 2011 à 17:41, Chantal Keller <chantal.keller@...> a
        écrit :

        > Hello Jeff,
        >
        > Le 06/05/2011 17:23, Jeff Massung a écrit :
        >> 1. How can I properly write my source file so that it can #load and
        >> compile
        >> without having to go back and forth editing my source file? For
        >> example:
        >>
        >> #load "unix.cma" ;;
        >> open Unix
        >> ...
        >>
        >> The above is perfect for the interpreter, but fails miserably when
        >> I try and
        >> compile. Similarly, I assume that if I tried to compile with ocamlopt
        >> instead of ocamlc that I'd need "unix.cmx" instead?
        >
        > Just remove [#load ...] and compile with:
        >
        > ocamlc -o myprog unix.cma myfile.ml
        > ocamlopt -o myprog unix.cmxa myfile.ml
        >
        > A nice way to compile OCaml programs without taking much care of such
        > things is to use OMake <http://omake.metaprl.org/index.html>.
        > --
        > Chantal KELLER
        >
        >
        > ------------------------------------
        >
        > Archives up to December 31, 2010 are also downloadable at http://www.connettivo.net/cntprojects/ocaml_beginners
        > The archives of the very official ocaml list (the seniors' one) can
        > be found at http://caml.inria.fr
        > Attachments are banned and you're asked to be polite, avoid flames
        > etc.Yahoo! Groups Links
        >
        >
        >
      Your message has been successfully submitted and would be delivered to recipients shortly.