# Use ROOT IO as library in a C++ stand alone project

**URL:** <https://root-forum.cern.ch/t/use-root-io-as-library-in-a-c-stand-alone-project/55539>\
**Category:** Evolution Proposals, Apps & Ideas\
**Tags:** tree\
**Created:** [July 4, 2023, 1:21pm UTC](https://root-forum.cern.ch/t/use-root-io-as-library-in-a-c-stand-alone-project/55539 "2023-07-04T13:21:07Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![atd](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/atd/32/33835_2.png) [@atd](https://root-forum.cern.ch/u/atd)\
**Post date:** [July 4, 2023, 1:21pm UTC](https://root-forum.cern.ch/t/use-root-io-as-library-in-a-c-stand-alone-project/55539/1 "2023-07-04T13:21:08Z")

</div>

Dear developers,

from time to time I am ask about how to use ROOT IO dictionaries in a stand alone C++ project.

I pushed the code into the [github](https://github.com/atolosadelgado/customTTreeExample), but maybe it can be a beneficial if it is adapted and distributed as part of the ROOT examples or tutorials.

The code creates a shared library and a ROOT dictionary for a given class, which is later used to write and read from a TTree.

The [ROOT documentation](https://root.cern/manual/io_custom_classes/) has improved a lot since I wrote that example, but I was not able to find a complete minimal working example of this ROOT feature.

I am at your disposal and happy to contribute 🙂

Best regards,  
Alvaro

---

<div class="post-metadata">

**Author:** ![jalopezg](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/jalopezg/32/25844_2.png) [@jalopezg](https://root-forum.cern.ch/u/jalopezg)\
**Post date:** [July 4, 2023, 8:08pm UTC](https://root-forum.cern.ch/t/use-root-io-as-library-in-a-c-stand-alone-project/55539/2 "2023-07-04T20:08:50Z")

</div>

Hi @atd,

Many thanks for the contribution! A simple example as this can actually be added as a tutorial, probably under `tutorials/tree/`. Usually, tutorial files include inline comments describing each step and/or general considerations.  
Are you up for making a pull request on the ROOT repository for this? Otherwise, we could discuss other possibilities.

> [@atd](#):
>
> The [ROOT documentation](https://root.cern/manual/io_custom_classes/) has improved a lot since I wrote that example, but I was not able to find a complete minimal working example of this ROOT feature.

Indeed, last year we dedicated two weeks to improve the documentation. We are happy to hear that the results are visible! 🙂

Cheers,  
J.

---

<div class="post-metadata">

**Author:** ![atd](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/atd/32/33835_2.png) [@atd](https://root-forum.cern.ch/u/atd)\
**Post date:** [July 5, 2023, 7:55am UTC](https://root-forum.cern.ch/t/use-root-io-as-library-in-a-c-stand-alone-project/55539/3 "2023-07-05T07:55:28Z")

</div>

Hi @jalopezg

I would be happy to do a PR on the ROOT repo 🙂

Cheers,  
Alvaro

---

<div class="post-metadata">

**Author:** ![couet](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/couet/32/12037_2.png) [@couet](https://root-forum.cern.ch/u/couet)\
**Post date:** [July 5, 2023, 8:21am UTC](https://root-forum.cern.ch/t/use-root-io-as-library-in-a-c-stand-alone-project/55539/4 "2023-07-05T08:21:23Z")

</div>

In a form of a tutorial ?

---

<div class="post-metadata">

**Author:** ![atd](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/atd/32/33835_2.png) [@atd](https://root-forum.cern.ch/u/atd)\
**Post date:** [July 5, 2023, 9:30am UTC](https://root-forum.cern.ch/t/use-root-io-as-library-in-a-c-stand-alone-project/55539/5 "2023-07-05T09:30:55Z")

</div>

Hi @couet

I was thinking to add the code inside a dedicated folder, something like `tutorials/tree/dictionary/`

as this other existing example: `tutorials/webgui/qtweb/`, with dedicated README.md and CMakelists files inside

would you prefer to just expand the webpage?

---

<div class="post-metadata">

**Author:** ![jalopezg](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/jalopezg/32/25844_2.png) [@jalopezg](https://root-forum.cern.ch/u/jalopezg)\
**Post date:** [July 5, 2023, 9:33am UTC](https://root-forum.cern.ch/t/use-root-io-as-library-in-a-c-stand-alone-project/55539/6 "2023-07-05T09:33:20Z")

</div>

Any preference, @couet?

IMHO, a tutorial would be awesome, provided that the documentation is extended (e.g., by explaining the required steps).

---

<div class="post-metadata">

**Author:** ![couet](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/couet/32/12037_2.png) [@couet](https://root-forum.cern.ch/u/couet)\
**Post date:** [July 5, 2023, 9:35am UTC](https://root-forum.cern.ch/t/use-root-io-as-library-in-a-c-stand-alone-project/55539/7 "2023-07-05T09:35:55Z")

</div>

Yes may be a dedicated folder is better. But as it is in `tree` I think we should ask @pcanal who is responsible of that part of the ROOT code. That’s up to him to decide.
