I was trying to import a module I have called
common.ml with the following syntax:
based on the tutorial/docs https://ocaml.org/learn/tutorials/modules.html I was reading they suggest to compile the modules. Thus I did:
$ ocamlopt -c common.ml
I got an error but I assume its safe to ignore it
File "common.ml", line 7, characters 2-25: 7 | Pervasives.print_string (str));; ^^^^^^^^^^^^^^^^^^^^^^^ Alert deprecated: module Stdlib.Pervasives Use Stdlib instead. If you need to stay compatible with OCaml < 4.07, you can use the stdlib-shims library: https://github.com/ocaml/stdlib-shims
however, when I try to run my file it can’t find the common module:
$ ocaml testing_imports.ml File "./testing_imports.ml", line 1: Error: Reference to undefined global `Common'
its contents is only the import statement:
What am I doing wrong? Am I not understanding how imports work in OCAML? I feel the tutorial doesn’t really explain what Im suppose to do…specially how OCAML finds modules (in general). Like how does it know its on the same directory? What if its else where? I’d like to start with something very simple first to see the basics and perhaps expand later.