Debug root script called with arguments

In Debug root script
it was found that a root script can be debugged by calling it with ++g.

root -l

How to format this command if I call the root script with arguments (Start root with a root file and script ):

root -l '"opt1", "opt2")'

Please read tips for efficient and successful posting and posting code

ROOT Version: Not Provided
Platform: Not Provided
Compiler: Not Provided

root.exe -l '"opt1", "opt2")'

Is it important to add .exe?
I work in Linux

When I call the script like that root does not recognise itself, e.g.

use of undeclared identifier 'TFile'

“root.exe” is the real executable which you want to debug (“root” is just a superfluous driver on top of it).

You seem to be missing: #include "TFile.h"

But normally it is not necessary to provide the #include's for root classes in root scripts. Where is the difference?

compiler versus interpreter

This time the script will be compiled rather than interpreted?

You explicitly ask for it using “++g” (as you want to debug it).

Then there is an incompatibility with such statements:

#include "ClassInCustomLib.hh"

The error is:

fatal error: ClassInCustomLib.hh: No such file or directory
 #include "ClassInCustomLib.hh"
compilation terminated.

What to do?

This is a known deficiency which nobody cares about: JIRA -> ROOT -> ROOT-10104

Create a simple “rootlogon.C” file (in the current working directory):

  if (gSystem->Getenv("CUSTOMLIB")) {

How do I accomodate this line:


I see a lot of errors like this:

script_cc_ACLiC_dict.cxx:(.text+0x1ebf): undefined reference to somefunction(TH1*)'


(.text+0x20): undefined reference to main’`

Does it mean I should rename int script() to int main()?

In the “rootlogon.C” file, add:


What to do for this line:


{ // rootlogon.C
  if (gSystem->Getenv("CUSTOMLIB")) {

Does gSystem have an equivalent of echo $LD_LIBRARY_PATH?

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.