I tried to compile an OCaml code with Dune but got the following error:
Error: No implementations provided for the following modules:
CallccBp referenced from bin/.CallccTest.eobjs/native/dune__exe__CallccTest.cmx
by executing the command : $ dune build
My project hierarchy is as follows:
callcc/
bin/
callccTest.ml
dune
[
(executable
(name callccTest)
(libraries CallccBp))
]
lib/
CallccBp.mli
dune
[
(library
(name CallccBp)
(modules_without_implementation CallccBp))
]
test/
callccTest.ml
dune [
(test
(name callccTest))
]
callcc.opam
dune-project
How can I solve this problem?
Looking at the discussion you had with octachron, let's start from the basics:
my_module.mli
my_module.ml
Let's see this with a toy project:
If I want to use values from
my_module
inbin/main.ml
, I have to:my_module.ml
(libraries my_module)
stanza in mybin/dune
fileMy_module.<name_of_value>
So this looks like:
Now, let's go back to your hierarchy:
Everything looks fine except from the fact that
CallccBp.mli
is just an interface, not an implementation. As a starter you could remove this file, createCallccBp.ml
filled with these two functions:CallccBp.ml
If you compile, dune should not complain and now all you'll have to do will be to provide a much useful implementation than
failwith "TODO"
And if we go back to our toy project, to see why you'd want to have an mli file:
I'll be able to use
My_module.incr
inbin/main.ml
but notMy_module.dummy
because it is not shown by themli
file and thus not accessible outside ofmy_module.ml
. And as a bonus,my_module.mli
file is the entry point for a library user who doesn't want to know how it is implemented but just wants to use it knowing the available values, their types and, often, what they do from the comment.The
modules_without_implementation
stanza is formli
files that don't need implementations, namely, type declarations files so modules looking like this:AST.mli
And you can use them in another file like this:
file.ml
But that's not really useful when starting since, once again, I'd advise not touching
mli
files in the beginning