# Adding include paths to CINT

**URL:** <https://root-forum.cern.ch/t/adding-include-paths-to-cint/8281>\
**Category:** ROOT\
**Created:** [May 6, 2009, 6:05pm UTC](https://root-forum.cern.ch/t/adding-include-paths-to-cint/8281 "2009-05-06T18:05:09Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![paulroachhair](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/p/8e8cbc/32.png) [@paulroachhair](https://root-forum.cern.ch/u/paulroachhair)\
**Post date:** [May 6, 2009, 6:05pm UTC](https://root-forum.cern.ch/t/adding-include-paths-to-cint/8281/1 "2009-05-06T18:05:09Z")

</div>

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

```auto
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

---

<div class="post-metadata">

**Author:** ![pcanal](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/pcanal/32/12439_2.png) [@pcanal](https://root-forum.cern.ch/u/pcanal)\
**Post date:** [May 6, 2009, 8:37pm UTC](https://root-forum.cern.ch/t/adding-include-paths-to-cint/8281/2 "2009-05-06T20:37:12Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![paulroachhair](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/p/8e8cbc/32.png) [@paulroachhair](https://root-forum.cern.ch/u/paulroachhair)\
**Post date:** [May 7, 2009, 5:29pm UTC](https://root-forum.cern.ch/t/adding-include-paths-to-cint/8281/3 "2009-05-07T17:29:30Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![pcanal](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/pcanal/32/12439_2.png) [@pcanal](https://root-forum.cern.ch/u/pcanal)\
**Post date:** [May 7, 2009, 6:21pm UTC](https://root-forum.cern.ch/t/adding-include-paths-to-cint/8281/4 "2009-05-07T18:21:16Z")

</div>

[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 🙂 :`gROOT->ProcessLine(".include .... ");`or call gInterpreter-\>AddIncludePath

Cheers,  
Philippe.

---

<div class="post-metadata">

**Author:** ![paulroachhair](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/p/8e8cbc/32.png) [@paulroachhair](https://root-forum.cern.ch/u/paulroachhair)\
**Post date:** [May 7, 2009, 9:37pm UTC](https://root-forum.cern.ch/t/adding-include-paths-to-cint/8281/5 "2009-05-07T21:37:32Z")

</div>

Roger that. Thanks Philippe.

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

```auto
[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] 
```
