Preprocess causes "Multiple rules generated for _build/default/bin/main2.pp.ml:" error

Hi everyone, when I write two executable stanza in dune file for “hello world” program, dune build is ok. This error occures when preprocess are added to both exectables below. Any ideas how to let dune build to compile. thx.

(executable
(public_name test_main)
(name main)
(libraries core_unix)
(preprocess (pps ppx_let ppx_jane))
)

(executable
(public_name test_main2)
(name main2)
(libraries core_unix)
(preprocess (pps ppx_let ppx_jane))
)

main.ml and main2.ml are just simple demo as below:

let () =
let open Core.Option.Let_syntax in
let%bind _a = Some 1 in
print_endline “Hello, World!”

error is as below when running dune build
1733893136277

Dune typically considers by default all modules in a directory as “belonging” to any stanza (executable, library) defined in that directory; if you want to define more than one stanza in a given directory, you need to specify the list of modules explicitly by adding a (modules ...) field to each stanza, so that the test_main stanza would need a (modules test_main) field and test_main2 stanza a (modules test_main2) field.

Cheers,
Nicolas

1 Like