Question regarding cling and include paths

Hi ROOT support,

I have a question regarding including files in the cling interpreter. I’m using ROOT 6.04.latest.

For normal compiling, I can use “-I/path/to/header” as an arg to the compiler and then in code “#include myheader.h” without hard coding the path in the source code (i.e. I don’t have to do #include “/path/to/header/myheader.h”).

Is it possible to have the same behavior in the itepretor? Specically I tried:

[rwk7t@tensor-3 cpp_projects]$  root
root [0] gSystem->AddIncludePath("-I/path/to/header")
root [1] std::cout << gSystem->GetIncludePath() << std::endl;
-I$ROOTSYS/include -I/path/to/header -I"/usr/local/root/6.04.00.patches/etc" -I"/usr/local/root/6.04.00.patches/include" -I"/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1" -I"/usr/local/root/6.04.00.patches/etc/cling" -I"." -I"/usr/local/root/6.04.00.patches" -I"/usr/local/root/6.04.00.patches/"
root [2] #include "myheader.h"
ROOT_prompt_4:1:10: fatal error: 'myheader.h' file not found
#include "myheader.h"
         ^

I naively I would have expected similar behavior as the compiler. Is there something wrong with my procedure? If this is not the correct procedure, can you point me to the “canonical” way this is expected to be done in ROOT 6? I don’t want to have to hard code the path as this is not sustainable for sharing code. Keep in mind that this is something that will be done frequently (and thus automated in logon scripts) to the many headers I need to include.

Thanks,
Ryan

Try:
gInterpreter->AddIncludePath("/path/to/header");

Excellent – that was it :smiley: !

Follow up question: What does gSystem->AddIncludePath() do then? Is it deprecated?

Thanks,
Ryan

gSystem->AddIncludePath() is not deprecated. It is used by AClic. There is a proposal to unify both.