I am writing my first small program with Ocaml and dune. It was going okay, until I discovered Ounit2 and tried to use it. I think I have gone through the proper steps:
- Installed ounit2 with “opam install ounit2”.
- Added ounit2 to my dune file in the test directory:
(test
(name test_ltc)
(libraries lib ounit2))
- Put 'open Ounit2" at the top of test.ltc.ml
But ‘dune build’ says ‘unbound module Ounit2’.
I can’t spot my mistake. Help!
Check the capitalization of the module name?
OUnit2
.
(I did the same thing. Multiple times.)
!!!
I feel so stupid. Thank you.
Oh. I forgot to change the capitalization in the dune file. It stills says:
(test
(name test_ltc)
(libraries lib ounit2))
But it doesn’t cause an error. I’d think it should be “oUnit2”. Is this dune phrase not case sensitive at all? (I’m still learning dune.)
Don’t. The computer is inhumane. This is an obvious case where spell-checking should be applied (“Did you mean?”).
This is a library name (a.k.a ocamlfind
package name, sadly it’s a bit complicated, read here). These names are usually lowercase, you can check them out with ocamlfind list
.