Dear Rooters,
I would like to specify a certain path where to look for headers included in a root macro.
I’d like this to be automatically done every time a run the macro.
According to the documentation, this can be done by:
gSystem->AddIncludePath(" -I<mypath> ")
I put a line like this in the corresponding rootlogon.C, but unfortunately it does not do the trick.
Let me describe it better with an example which I have compressed in the following file:
example.tar.gz (3.88 KB)
There you will find the root macro “example.C” a simple “Makefile” for the compilation (not needed, but it works), the rootlogon.C and a subdirectory “./inc” which contains a header file included in the “example.C” macro.
As a result of my tests, the macro compiles flawlessly, but it fails whenever is executed by root.
It cannot find the header file.
Somehow the command gSystem->AddIncludePath(" -I./inc ")
is not working.
If one simply executes root in the example directory, and then type .include, one can see the actual ROOT paths to include files:
[Behemoth] ~/example $> root
Setting the include path to: -I$ROOTSYS/include -I./inc -I"/usr/local/root_v5.34.09/include"
root [0] .include
include path: -I/usr/local/root_v5.34.09/include
root [1]
As you can see the the new path “./inc” has not been included.
The example works if I do:
[Behemoth] ~/example $> root
Setting the include path to: -I$ROOTSYS/include -I./inc -I"/usr/local/root_v5.34.09/include"
root [0] .include ./inc
root [1] .include
include path: -I/usr/local/root_v5.34.09/include -I./inc
root [2] .x example.C
Info in <TCanvas::Print>: pdf file example.pdf has been created
root [3]
But this is not a real solution because such an instance cannot be placed in the rootlogon.C.
Wait, I have just solved it while writing this post:
If in the rootlogon.C I write:
gROOT->ProcessLine(".include ./inc");
instead of gSystem->AddIncludePath(" -I./inc ");
it does work.
However, I think that this is a bug: The second instance should work too according to the documentation.
Cheers,
Alberto