When i try compile my scanner.ml with the command:
$ dune build scanner.exe
i receive the following message in my terminal:
Error: Don’t know how to build scanner.exe
Done: 0/0 (jobs: 0)
I’m using Ubuntu 20.04.1 LTS
dune build ./scanner.exe (need a leading
./ for executables in the current directory). I believe there is a hint for this… not sure why you’re not getting it with your setup.
If that doesn’t work, can you post the
dune file you’re using?
Dune builds according to the project layout. So if you have:
And if you are in the project root directory, then you can run:
dune build bin/scanner.exe
i pushed the project to:
For compile tests, i had build a hello world in:
The hello world worked to the command:
$ dune build ./hello.exe
But the scanner.ml doesn’t works with:
$ dune build ./scanner.exe
i’ am building in
$ dune build /src/scanner-adhoc/scanner.exe
Executables must be specified inside
(executable ...) stanzas in a
dune file in the same directory as the executable.
src/scanner-adhoc/dune, you define the executable
scanner-test, but no executable for the
scanner module, hence the error message. You could add a new stanza for
scanner, but then Dune will require you to specify which modules belong to which executables (which is a problem for your case, since
scanner-test requires code supplied by
If you want to define some common code that’s used by two executables, you should use a single library stanza and two executable stanzas that depend on it:
This will have the advantage of keeping your library code (
scanner) distinct from the run-time side-effects that it currently defines. (If you didn’t do this, any code that depends on
Scanner (in this case,
scanner-test) would end up inheriting its run-time side-effects too.) Even better, you could split the
scanner-adhoc folder into
test/ (each with their own
dune file), and then you wouldn’t need to tell Dune which modules correspond to which build artefacts.
Thanks @CraigFe. I understood how the build works!! And i separated the files in distint folders. Now i’m ready to resolved my asks about the implementation. Thanks again!!
scanner-test.ml is not a legal name for OCaml files. You’ll need to change it to
scanner_test.ml. And the module name will be