2

I'm attempting to build the xencat tool from this project. When I try to use ocamlopt to build it, I get

$ ocamlopt -o xencat xencat.ml 
File "xencat.ml", line 1, characters 5-13:
Error: Unbound module Cmdliner

Following guidance here, I verified that cmdliner was installed and that it was visible to ocamlfind, and then tried again:

Here's what ocamlfind list shows:

$ ocamlfind list
bigarray            (version: [distributed with Ocaml])
bytes               (version: [distributed with OCaml 4.02 or above])
...
cmdliner            (version: 0.9.8)
...

No luck:

$ ocamlfind ocamlopt -o xencat xencat.ml
File "xencat.ml", line 1, characters 5-13:
Error: Unbound module Cmdliner

Following this page, I tried ocamlbuild:

$ocamlbuild -use-ocamlfind xencat.byte
+ ocamlfind ocamlc -c -o xencat.cmo xencat.ml
File "xencat.ml", line 1, characters 5-13:
Error: Unbound module Cmdliner
Command exited with code 2.

Clearly I'm missing something, but being new to Ocaml, I don't know what else to try.

T.D. Smith
  • 984
  • 2
  • 7
  • 22
  • Try `ocamlfind ocamlopt -package cmdliner -o xencat xencat.ml`. – RichN Mar 04 '16 at 21:42
  • 1
    Ideally, you should use opam to install it. This package has dozens of dependencies, that should be satisfied before you can build this file. So, at first you need install them, presumably using opam – ivg Mar 04 '16 at 21:52

2 Answers2

2

ocamlbuild -use-ocamlfind -package cmdliner xencat.byte

?

gasche
  • 31,259
  • 3
  • 78
  • 100
  • A little progress! Now I'm getting a new Unbound module error, but I think it's telling me I need to build the whole project, not just this particular file. Can you explain why adding the `-package` argument was necessary? I expected ocamlbuild to find the package by itself. – T.D. Smith Mar 05 '16 at 12:57
  • 1
    None of the OCaml tools I know of will try to infer which ocamlfind packages you are using (there is not in general a well-defined mapping from OCaml module names, which the compilation and build tools see, to ocamlfind packages). You have to pass them explicitly. – gasche Mar 06 '16 at 22:29
1

To build this project use the following command at the root of the project:

./configure
make build

You will find a xencat.native file in the root folder.

You can also use opam to build it, as opam will handle all dependencies to you. Just go to the root of the project and say:

opam pin add vchan .

and answer yes to whatever opam asks to do.

ivg
  • 34,431
  • 2
  • 35
  • 63
  • Tried your first suggestion, I get `make build W: Cannot find source file matching module 'vchan' in library vchan Finished, 0 targets (0 cached) in 00:00:00. Finished, 40 targets (39 cached) in 00:00:00.` – T.D. Smith Mar 05 '16 at 01:13
  • I ended up doing `oasis setup-clean`, `make clean`, `./configure --xenctrl=true` and `make`. The binary was created. – T.D. Smith Mar 05 '16 at 15:43