List Info

Thread: "ocaml_beginners"::[] Re: .cmo file found, but module still unbound




"ocaml_beginners"::[] Re: .cmo file found, but module still unbound
user name
2007-01-27 17:15:30

"roparzhhemon&quot; < roparzhhemon%40yahoo.com.br">roparzhhemonyahoo.com.br> writes:

> I'm not quite sure I understand what you mean : in my example
> the "Special_dir&quot; subdirectory contains not only MyMod.cmo, but
> also MyMod.cmi and MyMod.ml (of course, they were all generated
> from MyMod.ml with ocamlc -c, which had no trouble with
>; different directories). Do you mean that MyMod.cmi should be moved
&gt; from Special_dir/ to / for the toplevel to work properly ?

I assume that you compiled your toplevel with command like:

ocamlmktop -I Special_dir -o mytoplevel MyMod.cmo

As indicated in the ocamlmktop section of the OCaml manual
(http://caml.inria.fr/pub/docs/manual-ocaml/manual023.html#htoc114),
the only functionality of option "-I directory&quot; is to add searching directory
"for compiled object code files"; to be linked with the new toplevel. In your
case, "-I Special_dir" did help ocamlmktop to find the place where MyMod.cmo
located, and MyMod.cmo was actually linked into the produced
mytoplevel. However, the "-I&quot; option doesn't says that the produced new
toplevel will remember the Special_dir, since it's of use to remember that --
you may move them all around in any time later (e.g. installation). So your
brand new toplevel doesn't know where the *interface* file MyMod.cmi is located
and can't help you to access this unknown module, even if you've already
embedded the implementation of .cmo file.

As Jonathan mentioned above, there is no straightforward way to ask the
produced new toplevel to remember this path, even if you may not intend to
move the MyMod.cmi to other directories. Give either of the following
conditions

- the absolute path of the MyMod.cmi's installation directory is know
- the relative path of MyMod.cmi's installation directory (to the new
toplevel's installation directory)

You can still play some tricks (e.g. a shell script with -I option or a
initialization caml program secretly adding the correct path) to get a
toplevel without having to put into "#directory XXX" manually each
time. However, I'm really doubting it's necessary in your case.

HTH

-code17

__._,_.___
.

__,_._,___
"ocaml_beginners"::[] Re: .cmo file found, but module still unbound
user name
2007-01-28 01:42:24

Thank you both for your help Jonathan and code17. Eventually I settled
for adding a "cp Special_dir/*.cmi ." in my makefile.

>This is a design decision, since both ocaml, ocamlc, and ocamlopt
>require the information present in the .cmi files -- which is all the
>typing information, etc.

Hmm. As a mere user I don't see the advantages of this with respect to
design. What I see is that it forces me to pack all the .cmi files in one
big directory, which gets in the way of the "Separate concepts-Separate places&quot;
design.

Ewan

__._,_.___
.

__,_._,___
Re: "ocaml_beginners"::[] Re: .cmo file found, but module still unbound
user name
2007-01-28 05:35:27

On Sun, Jan 28, 2007 at 07:42:24AM -0000, roparzhhemon wrote:
&gt; Thank you both for your help Jonathan and code17. Eventually I settled
> for adding a "cp Special_dir/*.cmi ." in my makefile.
>
> >This is a design decision, since both ocaml, ocamlc, and ocamlopt
> >require the information present in the .cmi files -- which is all the
> >typing information, etc.
>;
> Hmm. As a mere user I don't see the advantages of this with respect to
> design. What I see is that it forces me to pack all the .cmi files in one
> big directory, which gets in the way of the "Separate concepts-Separate places&quot;
> design.

I'm sure you've got this wrong though. I routinely develop using
different libraries in different directories and have never had this
problem. You must have forgotten to add the '-I' option or else
should be using #directory / .ocamlinit.

Rich.

--
Richard Jones
Red Hat UK Limited

__._,_.___
.

__,_._,___
[1-3]

about | contact  Other archives ( Real Estate discussion Medical topics )