Problem running example scripts with user defined classes

I am trying to run the example script tree2a.C , which can be found in $ROOTSYS/tutorials. The comments at the beginning of the script instruct

[quote]// to run the example, do:
// .x tree2a.C to execute with the CINT interpreter
// .x tree2a.C++ to execute with native compiler[/quote]
When I execute .x tree2a.C in root, I get the following error:

[quote]root [0] .x tree2a.C
Warning: Interpreted class Gctrak derived from precompiled class TObject FILE:tree2a.C LINE:22
!!!There are some limitations regarding compiled/interpreted class inheritance
SysError in TFile::TFile: file tree2.root can not be opened (Permission denied)
Error in TStreamerInfo::Build: Gctrak, discarding: Int_t* lmec, illegal [nmec]
Error in TStreamerInfo::Build: Gctrak, discarding: Int_t* namec, illegal [nmec]

*** Break *** segmentation violation
Generating stack trace…
0x40cfb296 in TBranchElement::FillLeaves(TBuffer&) + 0x398 from /opt/cmsbase/lcg/external/rootcore/3.10.02/rh73_gcc32/lib/
“[A lot more stuff from the trace]”
Root > Function tree2aw() busy flag cleared
Function tree2a() busy flag cleared

*** Break *** keyboard interrupt FILE: LINE:0
and root hangs at which point I do Ctrl-C.

In tree2a.C a class Gctrack is declared which is inherited from TObject. So after reading the CINT section of the ROOT User’s Guide on page 9 where it says that classes created in a script cannot inherit from TObject, I guess it makes since to get this error. But I wonder why the instructions say that .x tree2a.C should work.

Then I execute .x tree2a.C++ and I get the following error:

[quote]root [0] .x tree2a.C++
Info in TUnixSystem::ACLiC: creating shared library /home/birt/ROOT/tutorials/./
dlopen error: /home/birt/ROOT/tutorials/./ undefined symbol: DoError__C7TObjectiPCcT2Pv
Load Error: Failed to load Dynamic link library /home/birt/ROOT/tutorials/./
/usr/lib/gcc-lib/i386-redhat-linux/2.96/…/…/…/crt1.o: In function _start': /usr/lib/gcc-lib/i386-redhat-linux/2.96/../../../crt1.o(.text+0x18): undefined reference tomain’
“[A lot more stuff probably arising from the fact that was not loaded]”
/home/birt/ROOT/tutorials/./fileT6Xyu7.o: In function Gctrak::Gctrak(void)': /home/birt/ROOT/tutorials/./fileT6Xyu7.o(.Gctrak::gnu.linkonce.t.(void)+0x19): undefined reference toTObject::TObject(void)’
collect2: ld returned 1 exit status
*** Interpreter error recovered ***


When I try to run, using .x scriptname.C and .x scriptname.C++, any other scripts involving user defined classes I get similar errors, but all other scripts, including tree2.C, seem to work fine.

Could someone please tell me how to run the scripts involving user defined classes? It does not seem to be as simple as following the instructions in the tree2a.C example.

I have attached the full error statements in case that might help.
I am running ROOT Version 3.10/02.

tree2aCerror.txt (5.84 KB)
tree2aC++error.txt (16.8 KB)


tree2a.C is not supposed to work in the interpreter (at least not for the moment). It was a ‘bug’ in its documentation to claim it would.

This seems to indicate that either the version of gcc on your path (i.e. 2.96) is difference from the version used to compile the version of ROOT you are using. Either, your ROOTSYS environment and/or LD_LIBRARY_PATH points to a mismatch version of ROOT.


Thanks for the help. You were right, the version of gcc my system used by default was different from the one that compiled ROOT. I found the correct version and added it to my $PATH and it worked.