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

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:

.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


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:

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():

gSystem->AddIncludePath:  ;                              [User]

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


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:

.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

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

You can put there whatever you want.


Taking that and combing it with advice from this post, I put this into my rootlogon.C:


And there we go.

Thank you!