# Creating a custom debuggable file with dune

**URL:** <https://discuss.ocaml.org/t/creating-a-custom-debuggable-file-with-dune/10766>\
**Category:** Learning\
**Created:** [November 6, 2022, 3:48pm UTC](https://discuss.ocaml.org/t/creating-a-custom-debuggable-file-with-dune/10766 "2022-11-06T15:48:39Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![jonathandoyle](https://avatars.discourse-cdn.com/v4/letter/j/a3d4f5/32.png) [@jonathandoyle](https://discuss.ocaml.org/u/jonathandoyle)\
**Post date:** [November 6, 2022, 3:48pm UTC](https://discuss.ocaml.org/t/creating-a-custom-debuggable-file-with-dune/10766/1 "2022-11-06T15:48:39Z")

</div>

In my `dune` project, besides my `lib` directory I have a `debugging` directory containing just one ml file, called `debug_me.ml`.

In the (relatively infrequent) occasions when I need to do some debugging, I put the relevant piece of code in `debug_me.ml`, and then compile it (along with all its dependencies in the `lib` directory) with the `-g` option, and finally link them into an executable that can then be given as argument to `ocamldebug`.

I would like to write the dune file in that `debugging` directory so that invoking `dune build debugging` (or some equally simple command) will do exactly the set of actions I described in the preceding paragraph (after having put the code in `debug_me.ml`, that is ; this part I do myself by hand).

All I can think of so far is the following :

> (executable  
> (libraries lib)  
> )

But I don’t know how to tell `dune` to compile the modules in `lib` with the `-g` option. A search for `ocamldebug` in the `dune` manual gave no results.

---

<div class="post-metadata">

**Author:** ![rgrinberg](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ocaml.org/rgrinberg/32/40_2.png) [@rgrinberg](https://discuss.ocaml.org/u/rgrinberg)\
**Post date:** [November 6, 2022, 4:35pm UTC](https://discuss.ocaml.org/t/creating-a-custom-debuggable-file-with-dune/10766/2 "2022-11-06T16:35:52Z")

</div>

Dune already compiles everything with `-g` by default.
