ocamlopt and ocamlbuild give an Unbound module error despite ocamlfind seeing the required module

1.7k Views Asked by At

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.

2

There are 2 best solutions below

2
On BEST ANSWER

ocamlbuild -use-ocamlfind -package cmdliner xencat.byte

?

2
On

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.