Ocamlfind can't find threads.cmxa after adding `-package threads`

Well in fact I can perfectly reproduce your problem.

Eco-system tools always needs special casing around upstream provided libraries because they can’t be bothered.

What you see here is likely the result of some form of special casing in ocamlfind hitting back (a git grep on threads in ocamlfind’s sources will show the many potential offending locations).

The following command should actually compile the source you provided but it does not.

  1. It’s missing the -I to the ocaml/threads directory
  2. It locates the library in the ocaml libdir instead of ocaml/threads.

All this despite the META file being well aligned on ocamlfind’s convention (i.e. present in ocaml/threads and as provided above).

> ocamlfind ocamlopt -only-show -package threads -linkpkg a.ml
ocamlopt.opt -I /Users/dbuenzli/.opam/5.1.0/lib/ocaml/unix \
 /Users/dbuenzli/.opam/5.1.0/lib/ocaml/unix/unix.cmxa \
 /Users/dbuenzli/.opam/5.1.0/lib/ocaml/threads.cmxa \
 a.ml