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.mlimy_module.mlLet's see this with a toy project:
If I want to use values from
my_moduleinbin/main.ml, I have to:my_module.ml(libraries my_module)stanza in mybin/dunefileMy_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.mliis just an interface, not an implementation. As a starter you could remove this file, createCallccBp.mlfilled with these two functions:CallccBp.mlIf 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.incrinbin/main.mlbut notMy_module.dummybecause it is not shown by themlifile and thus not accessible outside ofmy_module.ml. And as a bonus,my_module.mlifile 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_implementationstanza is formlifiles that don't need implementations, namely, type declarations files so modules looking like this:AST.mliAnd you can use them in another file like this:
file.mlBut that's not really useful when starting since, once again, I'd advise not touching
mlifiles in the beginning