Bootstrapping a Project with Dune

Dune is recommended for bootstrapping projects. To install dune, please see the OCaml install page.

To start a new project, you can run:

$ opam exec -- dune init project hello_world
Success: initialized project component named hello_world

You can now build and run your new project:

$ cd hello_world
$ opam exec -- dune exec bin/main.exe
Hello, world!

To create a new library in the current project, use:

$ opam exec -- dune init lib my_lib ./path/to/my_lib
Success: initialized library component named my_lib

To create a new executable in the current project, use:

$ opam exec -- dune init exec my_bin ./path/to/my_bin
Success: initialized executable component named my_bin 

To create a new test in the current project, use:

$ opam exec -- dune init test my_test ./path/to/my_test
Success: initialized test component named my_test 

More Comprehensive Scaffolding

If you're looking for project templates that include more than the basics, there are other community projects that offer more comprehensive project scaffolding:

Help Improve Our Documentation

All OCaml docs are open source. See something that's wrong or unclear? Submit a pull request.

OCaml

Innovation. Community. Security.