Context: OCaml version 4.03
When trying to load_printer
in ocamldebug
, any dependencies of the module I’m trying to load are not automatically loaded. If module Foo
does an open Bar
, my session looks as follows:
(ocd) load_printer "foo.cmo"
Error during code loading: error while linking project/path/foo.cmo.
Reference to undefined global `Bar'
but if I explicitly load Bar
first, it does manage to load Foo
. From a concrete example (going down the stack of modules until reaching Core
's Poly
;
(ocd) load_printer "poly.cmo"
Error during code loading: error while linking my_project/src/third-party/core/core/bc/poly.cmo.
Reference to undefined global `Polymorphic_compare'
(ocd) load_printer "polymorphic_compare.cmo"
File my_project/src/third-party/core/core/bc/polymorphic_compare.cmo loaded
(ocd) load_printer "poly.cmo"
File my_project/src/third-party/core/core/bc/poly.cmo loaded
See? After I successfully load polymorphic_compare.cmo
, I can load poly.cmo
. This would be just a minor annoyance if my project didn’t also depend on, for example, str.cmo
, which doesn’t live in the include paths of my project.
Weirdly, when I have printers_dep.ml
:
type printer_test = PrinterTest of string
and printers.ml
:
open Printers_dep
let foo : printer_test = PrinterTest "foo"
let bar : printer_test = PrinterTest "bar"
let pp_printer_test (PrinterTest s) = Format.print "<<%s>>" s
and compile and load my project with it, I can transitively load printers_dep.cmo
;
(ocd) load_printer "printers.cmo"
File my_project/src/bc/printers.cmo loaded
(ocd) install_printer Printers.pp_printer_test
(ocd) p Printers.foo
Printers.foo: Printers.printer_test = <<foo>>
everything works how I would expect it to work.
Is there any reason why the modules I want to load fail to load, based on their dependencies? Is there a way around this or at least a way to find out in more detail what’s going on?