Ocamlbuild error for a module that is installed

hi,

To be honest, I’m not too fond of ocamlbuild. It seems to me that a lot of magic is going on in the background, so when stuff is not working its hard to figure out the reason. In this case ocamlbuild complains about a missing Ocb_stubblr module even it is installed.

$ ocamlfind list | grep ocb

ocb-stubblr         (version: 0.1.1)
ocb-stubblr.topkg   (version: 0.1.1)

The thing I’d like to build is the tests of the ‘tsdl’ package (GitHub - dbuenzli/tsdl: Thin bindings to SDL for OCaml)

$ ocamlbuild -use-ocamlfind tests.otarget

  • ocamlfind ocamlopt unix.cmxa -I /Users/bkb/.opam/4.02.3/lib/ocaml/ocamlbuild /Users/bkb/.opam/4.02.3/lib/ocaml/ocamlbuild/ocamlbuildlib.cmxa -linkpkg myocamlbuild .ml /Users/bkb/.opam/4.02.3/lib/ocaml/ocamlbuild/ocamlbuild.cmx -o myocamlbuild
    File “myocamlbuild .ml”, line 2, characters 5-16:
    Error: Unbound module Ocb_stubblr
    Command exited with code 2.
    Compilation unsuccessful after building 1 target (0 cached) in 00:00:00.

Any ideas?

As far as I can tell, the test line documented in the README is wrong for two reasons:

  • you need to tell ocamlbuild that myocamlbuild.ml needs to be compiled with the ocb-stubblr package by passing the -plugin-tag 'package(ocb-stubblr)' command-line option
  • the target tests.otargetneeds a file test.itarget listing the test programs to build, and this file does not seem to exist in the repository

The following line works:

ocamlbuild -use-ocamlfind -plugin-tag 'package(ocb-stubblr)' test/test_audio_queue.native

(cc @dbuenzli)

Note that the -plugin-tag option, and in general the build process for myocamlbuild.ml files, is documented in the ocamlbuild manual: 3.1 how myocamlbuild.ml is used.

Yes it’s outdated. Simply use topkg build, topkg test --list will give you the list of tests that you can run by using the same command.