I have the peculiar situation that i can successfully compile and run the native code version of my dynlinked code but not the bytecode version. Who has an idea what I am doing wrong?!
I am using the following setup to dynamically load a module
The relevant source files:
base.ml m_setup.ml run.ml run1/m_dyn.ml run2/m_dyn.ml ...
base.ml: general library code used throughout.
m_setup.ml: common parameter settings for all runs
open Base include M_setup (*...specific parameter settings for run <i>*)
open Base let subdir = Sys.argv.(1) Dynlink.( loadfile (Filename.concat subdir (adapt_filename "m_dyn.cmo"))) (* now run stuff with the loaded parameter settings *)
I am using ocamlbuild for building (no time for conversion to dune right now).
I can successfully build
run.native and then run
I can also build
run.byte, but on running
./run.byte run1 i get the error:
Dynlink error: error while linking _build/run1/m_dyn.cmo. Reference to undefined global `M_setup'
(edit: this is a simplified version of my actual example, with what i hope are the relevant bits. both m_dyn and run are compiled against the same interface, which is why the native version does work fine - i did not explicitly list that interface file. for the sake of the example, let’s say the interface is included in