Install cmt along with packages for merlin jump-to-definition

Recently, I tried to setup development environment with ocamlbuild + merlin for a project that depends on external packages, e.g. ocamlgraph.

What I noticed is that I was not able to jump to definitions of functions or types defined in Graph.

My guess is that opam install doesn’t download *.cmt file by default, so I need to somehow locate those to right location.

Are there any options that I can download *.cmt files along with opam packages? Or simply how I can get those bit-annot files for opam packages?

1 Like

A possible solution to this problem is to manually add the _build folder to the .merlin file in your project root directory. You will need to keep the build files of the external dependencies by doing opam install -b --deps-only first, however.

See How to get merlin to do a good job on project dependencies? How to get dune to generate better .merlin files? for more details.

In the case of ocamlgraph, this is not an opam issue, this is a build system issue. To expand a bit, it’s up to each build system to tell opam what to install: mli files, cma files, cmt files, etc. A build system like dune will do the right thing by default and install cmt/cmti files, but older packages like ocamlgraph deal with their installation by hand using a Makefile.

There’s a dune port (that should install cmt files) at You can also try to patch the Makefile, but in the long run I think it’s better to adapt the build system so that this is taken care of automatically.