Adding include paths to CINT

I’m finding that this doesn’t work as the User Guide describes. See below:

root [0] .! ls $CINT_INCLUDE                             
fcheck.h  load_tree.h  tof_index.h  toftw.h
root [1] gSystem->AddIncludePath(" -I$CINT_INCLUDE ")    
root [2] gSystem->GetIncludePath()                       
(const char* 0x9b79ab8)"-I$ROOTSYS/include  -I$CINT_INCLUDE   -I\"/local/scratch/root/include\"  -I\"/local/scratch/root/include/cint\" "
root [3] #include <fcheck.h>
Error: cannot open file "fcheck.h"  (tmpfile):2:
*** Interpreter error recovered ***
root [4] #include <load_tree.h>
Error: cannot open file "load_tree.h"  (tmpfile):2:
*** Interpreter error recovered ***
root [5] .! cat $CINT_INCLUDE/fcheck.h
#ifndef FCHECK_H
#define FCHECK_H

#include <exception>
#include <fstream>
#include <string>
#include <sstream>

const ifstream& fcheck(std::string fname, std::string desc) {
  ifstream f(fname.c_str());
  if (!f.good()) {
    stringstream ss;
    ss << "File with" << desc << " constants `" << fname 
       << "' not found. Aborting...";
    throw std::exception("File not found.");
  }
  return f;
}

#endif //FCHECK_H
root [6] .include $CINT_INCLUDE
root [7] #include <fcheck.h>
Error: cannot open file "fcheck.h"  (tmpfile):2:
*** Interpreter error recovered ***
root [8] .include           
include path: -I/local/scratch/root/include -I$CINT_INCLUDE 
root [9] .include /home/craigb/workspace/HallB/macros/include
root [10] #include <fcheck.h>                                 
Warning in <TClass::TClass>: no dictionary for class exception is available
root [11] 

The $CINT_INCLUDE directory is also part of my macro path.

Ideas? TIA

Hi,

This behaves as I would expect (albeit not quite intuitively and we are indeed trying to find a way to improve the situation)>

gSystem->GetIncludePath()is only used when the file or script is loaded via ACLiC. For interpreted file you need to use “.include …” which does not expand shell variables.

Cheers,
Philippe.

PS. Can you remind me where the User’s Guide is contradicting this?

The page in the User’s Guide that I was referring to is page 94 (in the CINT section). It just says something like “here’s what you do to add an include path within a script.” I was hoping to be able to put a line in my rootlogon.C file to add my include path and then from there be able to include files from that path in any capacity.

So am I understanding you correctly if I say:

  • to run (interpret) a script with include files in a nonstandard location, i must use the “.include” command–there’s no way to set this up in my rootlogon.C
  • to compile a script with ACLiC and run it, the gSystem->AddIncludePath() method should work

[quote] to run (interpret) a script with include files in a nonstandard location, i must use the “.include” command–there’s no way to set this up in my rootlogon.C [/quote]There is at least 2 ways :slight_smile: :gROOT->ProcessLine(".include .... ");or call gInterpreter->AddIncludePath

Cheers,
Philippe.

Roger that. Thanks Philippe.

If anyone else gets confused about this, here’s what works:

[craigb@fsul1 ~]$ ls /home/craigb/workspace/HallB/macros/include/            
load_tree.h  tof_index.h  toftw.h
[craigb@fsul1 ~]$ root
root [0] gInterpreter->AddIncludePath("/home/craigb/workspace/HallB/macros/include")
root [1] #include<load_tree.h>
root [2] #include<tof_index.h>
root [3] #include<toftw.h>
root [4] bada bing.
Error: Symbol badabing is not defined in current scope  (tmpfile):1:
Error: Failed to evaluate badabing.
*** Interpreter error recovered ***
root [5]