# Getting PYTHIA to work with ROOT

**URL:** <https://root-forum.cern.ch/t/getting-pythia-to-work-with-root/42978>\
**Category:** Newbie\
**Created:** [January 6, 2021, 4:26pm UTC](https://root-forum.cern.ch/t/getting-pythia-to-work-with-root/42978 "2021-01-06T16:26:32Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Jacob\_Repucci](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/jacob_repucci/32/24488_2.png) [@Jacob\_Repucci](https://root-forum.cern.ch/u/Jacob_Repucci)\
**Post date:** [January 6, 2021, 4:26pm UTC](https://root-forum.cern.ch/t/getting-pythia-to-work-with-root/42978/1 "2021-01-06T16:26:32Z")

</div>

* * *

_ROOT Version:_ 6.22  
_Platform:_ MacOS  
_Compiler:_ Not Provided

* * *

I downloaded ROOT using brew install on my mac. I also downloaded Pythia, but it appears that my C++ code doesn’t recognize any Pythia-based include statements. I’ve found out that if I were using CMake I would need to rebuild ROOT with pythia enabled. Is there a way to do that with brew install instead?

---

<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:** [January 6, 2021, 7:07pm UTC](https://root-forum.cern.ch/t/getting-pythia-to-work-with-root/42978/2 "2021-01-06T19:07:15Z")

</div>

may be @oshadura has an idea ?

---

<div class="post-metadata">

**Author:** ![Axel](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/axel/32/11084_2.png) [@Axel](https://root-forum.cern.ch/u/Axel)\
**Post date:** [January 7, 2021, 3:27pm UTC](https://root-forum.cern.ch/t/getting-pythia-to-work-with-root/42978/3 "2021-01-07T15:27:11Z")

</div>

You don’t need to rebuild ROOT to use Pythia - only to use `TPythia8`. If you just use Pythia directly then you’ll just need to teach your `CMakeLists.txt` where to find it.

---

<div class="post-metadata">

**Author:** ![Jacob\_Repucci](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/jacob_repucci/32/24488_2.png) [@Jacob\_Repucci](https://root-forum.cern.ch/u/Jacob_Repucci)\
**Post date:** [January 7, 2021, 4:22pm UTC](https://root-forum.cern.ch/t/getting-pythia-to-work-with-root/42978/4 "2021-01-07T16:22:37Z")

</div>

Sounds simple enough!

How exactly do I teach `CMakeLists.txt` where to find it?

---

<div class="post-metadata">

**Author:** ![oshadura](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/oshadura/32/14460_2.png) [@oshadura](https://root-forum.cern.ch/u/oshadura)\
**Post date:** [January 8, 2021, 9:31am UTC](https://root-forum.cern.ch/t/getting-pythia-to-work-with-root/42978/5 "2021-01-08T09:31:14Z")

</div>

Can you please post your CMakeLists file? Ideally you need to use something like: `find_package(Pythia8 REQUIRED)` together with adding `FindPythia8.cmake` file [https://github.com/root-project/root/blob/master/cmake/modules/FindPythia8.cmake](https://github.com/root-project/root/blob/master/cmake/modules/FindPythia8.cmake). Next step will be to link your code with $PYTHIA8\_LIBRARY and include $PYTHIA8\_INCLUDE\_DIR in your CMake code. I think you can find some examples just simply googling.

---

<div class="post-metadata">

**Author:** ![Jacob\_Repucci](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/jacob_repucci/32/24488_2.png) [@Jacob\_Repucci](https://root-forum.cern.ch/u/Jacob_Repucci)\
**Post date:** [January 8, 2021, 7:24pm UTC](https://root-forum.cern.ch/t/getting-pythia-to-work-with-root/42978/6 "2021-01-08T19:24:14Z")

</div>

Here’s the CMakeLists file:

[CMakeLists.txt](https://root-forum.cern.ch/uploads/short-url/sZhejpKJVSTfvfRJZZcH7HZwEn3.txt) (23.1 KB)

There’s a `find_package` statement that says `ROOT REQUIRED`. Should I write another statement below that says `Pythia8 REQUIRED`?
