4

I am having trouble adding adding a library to ocamlmktop.

I have a directory com, with an object file com/com.cma.

If I run ocamlmktop com.cma -o top within the com directory, then the resulting executable top seems to have the library; i.e, I can enter "Com.foo;;" and it will give the type signature of foo in the module Com.

However, if I run ocamlmktop com/com.cma -o top within the directory above com, then the resulting executable does not seem to have the library; i.e, it responds to "Com.foo;;" with "Error: Unbound module Com".

Is there a way to include libraries from different folders, or do I need to put all the .cma files in the same folder?

Also, I'm using the OASIS build system; can I inform OASIS that I want a toplevel with these libraries?

Edit:

I've found a partial solution: ocamlc -pack a/a.cmo b/b.cmo -o everything.cmo, and then ocamlmktop everything.cmo -o top; however, this requires duplicating all the libraries and forces them to be submodules of a single supermodule.

Samir Jindel
  • 163
  • 1
  • 4

1 Answers1

2

The reason that you cannot use toplevel from the directory above is that toplevels do not include interface files (.cmi) and the toplevel needs to find them on disk when the user accesses some module. So, either load toplevel with -I com switch or after loading issue #directory "com";;.

NB OASIS should support building toplevels natively in the next release (0.4.0).

ygrek
  • 6,656
  • 22
  • 29
  • 1
    oasis still doesn't support building toplevels, but it is easy to do manually - just create usual `top.mltop` file with list of modules and call `ocamlbuild top.top` and run the toplevel so that it can access build artifacts : `CAML_LD_LIBRARY_PATH=_build:$CAML_LD_LIBRARY_PATH ./top.top -I _build` – ygrek Mar 25 '14 at 04:38