# How do I append to the include path using .rootrc or rootlogon.C?

**URL:** <https://root-forum.cern.ch/t/how-do-i-append-to-the-include-path-using-rootrc-or-rootlogon-c/49506>\
**Category:** Newbie\
**Created:** [April 7, 2022, 7:31am UTC](https://root-forum.cern.ch/t/how-do-i-append-to-the-include-path-using-rootrc-or-rootlogon-c/49506 "2022-04-07T07:31:14Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![jaysonl](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/jaysonl/32/29368_2.png) [@jaysonl](https://root-forum.cern.ch/u/jaysonl)\
**Post date:** [April 7, 2022, 7:31am UTC](https://root-forum.cern.ch/t/how-do-i-append-to-the-include-path-using-rootrc-or-rootlogon-c/49506/1 "2022-04-07T07:31:14Z")

</div>

Hello again.

I use ROOT for prototyping bits of code, and at the moment, I happen to be working with GLib a lot.

The paths for these header files aren’t in the default include path, so I find myself having to perform this little ritual every time I start ROOT:

```auto
.I /usr/include/glib-2.0
.I /usr/lib/x86_64-linux-gnu/glib-2.0/include

```

I don’t mind this, for the most part, except if I ever _forget_ to add these paths before I try to `#include <glib.h>`, root decides that it doesn’t want to play nicely with me any more, and `#include <glib.h>` will never work, even if I issue the above `.I` commands. It’s like it’s cached the idea that glib.h doesn’t exist, so it couldn’t possibly ever exist ever again… which means I have to trash my entire ROOT session and start again.

So, I’d like to just add these paths to some sort of startup file. My research has lead me to two types of startup file — .rootrc and rootlogon.C

# rootrc

I’ve learned that if I put a `.rootrc` file in my home directory, it’ll get read, and its syntax has something to do with the definitions that come up if I run `gEnv->Print()`. But, when I look through the output of `gEnv->Print()`, nothing look like an include path.

Skimming around through documentation, I got the impression that doing something like this:

```auto
gSystem->AddIncludePath(" -I/usr/include/glib-2.0 ");
gSystem->AddIncludePath(" -I/usr/lib/x86_64-linux-gnu/glib-2.0/include ");

```

would allow me to add directories to the include path. I can run the commands from ROOT, but `#include <glib.h>` still fails after I’ve done so.

I tried adding those lines to `.rootrc`, and it did _something_, as I get this additional line at the end when I run `gEnv->Print()`:

```auto
gSystem->AddIncludePath: ; [User]

```

, but once again, it doesn’t help with the include statement.

# rootlogon.C

I also heard of a rootlogon.C file that gets read from your current directory. While not the ideal solution (I’d like these additions to the include path to be made regardless of which directory I start ROOT in), but if I try to just add `.I` lines to rootlogon.C like so:

```auto
.I /usr/include/glib-2.0
.I /usr/lib/x86_64-linux-gnu/glib-2.0/include

```

ROOT chastises me, saying that I “cannot use dot operator on a type”.

# what do?

I figure this _has_ to be a common use case, but 20+ minutes of digging around, and I haven’t found a definitive answer to “how do I add to the include path?”

Any pointers?

* * *

_ROOT Version:_ 6.26/00  
_Platform:_ linuxx8664gcc  
_Compiler:_ c++ (Ubuntu 11.2.0-7ubuntu2) 11.2.0

* * *

---

<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:** [April 7, 2022, 7:37am UTC](https://root-forum.cern.ch/t/how-do-i-append-to-the-include-path-using-rootrc-or-rootlogon-c/49506/2 "2022-04-07T07:37:14Z")

</div>

> [@rootlogon.C documentation](https://root-forum.cern.ch/t/rootlogon-c-documentation/49150/11):
>
> Well, to be precise, the order is as follows: “$(root-config --etcdir)/system.rootlogon.C” “${HOME}/.rootlogon.C” “${PWD}/.rootlogon.C” but only if “${PWD}” != “${HOME}” the file defined by “Rint.Logon” which exists in “TROOT::GetMacroPath()”, so, by default (see the “$(root-config --etcdir)/system.rootrc” file), it will be either “${PWD}/rootlogon.C” or “${ROOTSYS}/macros/rootlogon.C”

---

<div class="post-metadata">

**Author:** ![jaysonl](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/jaysonl/32/29368_2.png) [@jaysonl](https://root-forum.cern.ch/u/jaysonl)\
**Post date:** [April 7, 2022, 3:01pm UTC](https://root-forum.cern.ch/t/how-do-i-append-to-the-include-path-using-rootrc-or-rootlogon-c/49506/3 "2022-04-07T15:01:49Z")

</div>

Cool to know… but can I put things to append to my include path in them?

---

<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:** [April 7, 2022, 3:17pm UTC](https://root-forum.cern.ch/t/how-do-i-append-to-the-include-path-using-rootrc-or-rootlogon-c/49506/4 "2022-04-07T15:17:50Z")

</div>

You can put there whatever you want.

> [@rootlogon.C documentation](https://root-forum.cern.ch/t/rootlogon-c-documentation/49150/2):
>
> In any ROOT version (also in ROOT 5), either an “unnamed” macro (I somehow remember that the “{” needed to be the very first line in an “unnamed” macro): { // ... } or a “named” macro: void rootlogon() { // ... }

---

<div class="post-metadata">

**Author:** ![jaysonl](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/jaysonl/32/29368_2.png) [@jaysonl](https://root-forum.cern.ch/u/jaysonl)\
**Post date:** [April 7, 2022, 3:33pm UTC](https://root-forum.cern.ch/t/how-do-i-append-to-the-include-path-using-rootrc-or-rootlogon-c/49506/5 "2022-04-07T15:33:47Z")

</div>

_Ahha!_

Taking that and combing it with advice from [this post](https://root-forum.cern.ch/t/adding-include-paths-to-cint/8281/4), I put this into my `rootlogon.C`:

```auto
{
	gInterpreter->AddIncludePath("/usr/include/glib-2.0");
	gInterpreter->AddIncludePath("/usr/lib/x86_64-linux-gnu/glib-2.0/include");
}

```

And there we go.

Thank you!
