# Compilation fails including .hpp files

**URL:** <https://root-forum.cern.ch/t/compilation-fails-including-hpp-files/47250>\
**Category:** Newbie\
**Created:** [October 15, 2021, 9:37am UTC](https://root-forum.cern.ch/t/compilation-fails-including-hpp-files/47250 "2021-10-15T09:37:56Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![zenith378](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/zenith378/32/31705_2.png) [@zenith378](https://root-forum.cern.ch/u/zenith378)\
**Post date:** [October 15, 2021, 9:37am UTC](https://root-forum.cern.ch/t/compilation-fails-including-hpp-files/47250/1 "2021-10-15T09:37:56Z")

</div>

Hello everyone,  
so I’d like to draw some bayesian blocks histograms and the only algorithm that was already implemented in C++ I could find is [this one on GitHub](https://github.com/gipert/bayesian-blocks).

It really seems to suit what i need, so I downloaded the zip file and copied the headers file (“baeysian\_blocks.hpp” and “baeysian\_blocks\_root.hpp”) in the “include” folder where all the others include files for root are.  
But when I compile my code I get an error

> ./Events.h:11:10: fatal error: ‘baeysian\_blocks.hpp’ file not found  
> #include “baeysian\_blocks.hpp”  
> ^  
> 1 error generated.

Sorry if this may sound dumb, but i’m not really an expert at programming, and i could really use some help.  
Thanks in advance.

* * *

\_ROOT Version: 6.11/02  
_Platform:_ OS X 10.11.6  
_Compiler:_ gcc

* * *

---

<div class="post-metadata">

**Author:** ![Wile\_E\_Coyote](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/wile_e_coyote/32/12417_2.png) [@Wile\_E\_Coyote](https://root-forum.cern.ch/u/Wile_E_Coyote)\
**Post date:** [October 15, 2021, 9:51am UTC](https://root-forum.cern.ch/t/compilation-fails-including-hpp-files/47250/2 "2021-10-15T09:51:18Z")

</div>

Try something like this:  
`$(root-config --cxx --cflags) -o YourExecutable YourSourceCode.cxx $(root-config --libs)`

---

<div class="post-metadata">

**Author:** ![zenith378](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/zenith378/32/31705_2.png) [@zenith378](https://root-forum.cern.ch/u/zenith378)\
**Post date:** [October 15, 2021, 9:56am UTC](https://root-forum.cern.ch/t/compilation-fails-including-hpp-files/47250/3 "2021-10-15T09:56:31Z")

</div>

> [@Wile\_E\_Coyote](#):
>
> `$(root-config --cxx --cflags) -c YourSourceCode.cxx`

Thanks for the very quick reply. I tried but it doesn’t seem to work, I get exactly the same error.

P.S.  
I omitted in the first post but i usually compile with the command

```auto
g++ `root-config --cflags` `root-config --libs` Events.C -o eve

```

---

<div class="post-metadata">

**Author:** ![Wile\_E\_Coyote](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/wile_e_coyote/32/12417_2.png) [@Wile\_E\_Coyote](https://root-forum.cern.ch/u/Wile_E_Coyote)\
**Post date:** [October 15, 2021, 9:58am UTC](https://root-forum.cern.ch/t/compilation-fails-including-hpp-files/47250/4 "2021-10-15T09:58:37Z")

</div>

Try (see if the listed compiler and include directory is what your expect): `root-config --cxx --cflags`

---

<div class="post-metadata">

**Author:** ![zenith378](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/zenith378/32/31705_2.png) [@zenith378](https://root-forum.cern.ch/u/zenith378)\
**Post date:** [October 15, 2021, 10:06am UTC](https://root-forum.cern.ch/t/compilation-fails-including-hpp-files/47250/5 "2021-10-15T10:06:49Z")

</div>

Yeah, it’s exactly the folder where I copied the .hpp files. It’s the same folder where all the ROOT .h files are located.

---

<div class="post-metadata">

**Author:** ![Wile\_E\_Coyote](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/wile_e_coyote/32/12417_2.png) [@Wile\_E\_Coyote](https://root-forum.cern.ch/u/Wile_E_Coyote)\
**Post date:** [October 15, 2021, 10:08am UTC](https://root-forum.cern.ch/t/compilation-fails-including-hpp-files/47250/6 "2021-10-15T10:08:41Z")

</div>

Try (see if these files are “readable” to you):  
`ls -al $(root-config --incdir)/baeysian_*.hpp`

---

<div class="post-metadata">

**Author:** ![zenith378](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/zenith378/32/31705_2.png) [@zenith378](https://root-forum.cern.ch/u/zenith378)\
**Post date:** [October 15, 2021, 10:18am UTC](https://root-forum.cern.ch/t/compilation-fails-including-hpp-files/47250/7 "2021-10-15T10:18:56Z")

</div>

Ok, not really sure of what I’m doing. In which directory should I wirte the command you gave me? I get an output like

> ls -al $(root-config --incdir)/baeysian\_\* .hpp  
> -bash: root-config: command not found  
> ls: /baeysian\_\*.hpp: No such file or directory

---

<div class="post-metadata">

**Author:** ![Wile\_E\_Coyote](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/wile_e_coyote/32/12417_2.png) [@Wile\_E\_Coyote](https://root-forum.cern.ch/u/Wile_E_Coyote)\
**Post date:** [October 15, 2021, 10:22am UTC](https://root-forum.cern.ch/t/compilation-fails-including-hpp-files/47250/8 "2021-10-15T10:22:20Z")

</div>

It seems you have not setup your ROOT. You first need to, e.g.:  
`source /full/path/to/your/ROOT/bin/thisroot.sh`

---

<div class="post-metadata">

**Author:** ![zenith378](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/zenith378/32/31705_2.png) [@zenith378](https://root-forum.cern.ch/u/zenith378)\
**Post date:** [October 15, 2021, 10:30am UTC](https://root-forum.cern.ch/t/compilation-fails-including-hpp-files/47250/9 "2021-10-15T10:30:25Z")

</div>

Ok, now i did set up my ROOT. Tried to re run the command you gave me and i get

> ls: /Users/Zenith/root/include/baeysian\_\*.hpp: No such file or directory

or

> ls: /Users/Zenith/root/include/baeysian\_blocks\_root.hpp: No such file or directory

Instead, if I try something like

> ls -al $(root-config --incdir)/\*.hpp

i get

> -rwxr-xr-x@ 1 Zenith staff 6842 11 Giu 08:50 /Users/Zenith/root/include/bayesian\_blocks.hpp  
> -rwxr-xr-x@ 1 Zenith staff 3182 15 Ott 11:59 /Users/Zenith/root/include/bayesian\_blocks\_root.hpp

---

<div class="post-metadata">

**Author:** ![Wile\_E\_Coyote](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/wile_e_coyote/32/12417_2.png) [@Wile\_E\_Coyote](https://root-forum.cern.ch/u/Wile_E_Coyote)\
**Post date:** [October 15, 2021, 10:32am UTC](https://root-forum.cern.ch/t/compilation-fails-including-hpp-files/47250/10 "2021-10-15T10:32:54Z")

</div>

So, it’s “baeysian” against “bayesian” (the winner takes it all).

---

<div class="post-metadata">

**Author:** ![zenith378](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/zenith378/32/31705_2.png) [@zenith378](https://root-forum.cern.ch/u/zenith378)\
**Post date:** [October 15, 2021, 10:44am UTC](https://root-forum.cern.ch/t/compilation-fails-including-hpp-files/47250/11 "2021-10-15T10:44:08Z")

</div>

> [@Wile\_E\_Coyote](#):
>
> the winner takes it all

Thank you very much, thanks for the lot of trouble!
