Why the error indicate TTree::TTree not defined?

when i make a garfield++ project based on root, if not insert the code below:
TTree *e_position=new TTree(“e”,“E Position”);

e_position->Branch(“xe”,&xe,“xe/F”);

e_position->Branch(“ye”,&ye,“ye/F”);

e_position->Branch(“ze”,&ze,“ze/F”);

e_position->Branch(“te”,&te,“te/F”);
the program worked well.

wher the code up insert(with the header file <TTree.h> on) :
the error occurs below:
signal.C:(.text+0x561): undefined reference to `TTree::TTree(char const*, char const*, int, TDirectory*)’

it seems TTree class constructor function is no found, but when use root program only the TTree class
works well, how the mistake occurs? please help me, thanks!

_
Please read tips for efficient and successful posting and posting code

ROOT Version: 6.22/06
_Platform:_Ubuntu20
Compiler: Gcc 9.3.0


You need to link against libTree.

the code #include <TTree.h> has appended

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