Undefined reference to 'typeinfo ...' in TTree

Dear Colleagues,

I have a trouble with reading a TTree containing objects of class ‘particle_event’, which is my own class. The piece of code I’m using to read it looks as following:

gROOT->ProcessLine(".L particle_event.cxx+");

particle_event  *particle_events;

TFile *f = new TFile("threeRuns.el.root");
TTree *PicoTree = new TTree();
f->GetObject("PicoTree;1", PicoTree);

PicoTree->SetBranchAddress("particle_events",&particle_events); // <-- line producing linking error

// ....

The message from compiler is:

/tmp/ccJMDx7g.o: In function `int TTree::SetBranchAddress<particle_event>(char const*, particle_event**, TBranch**)':
/usr/cern/root/include/TTree.h:495: undefined reference to `typeinfo for particle_event'
/usr/cern/root/include/TTree.h:497: undefined reference to `typeinfo for particle_event'
collect2: ld returned 1 exit status

I’m using g++ 4.6.3 on Kubuntu 12.04. My makefile is shown below:

ALLSRC=selector.C Expr.cpp Logical.cpp Eq.cpp Lt.cpp Gt.cpp And.cpp Or.cpp Cut.cpp EventSelector.cpp
EXEC=selector
CXX=`root-config --cxx`
CXXFLAGS=`root-config --cflags`
LDFLAGS=`root-config --ldflags`
LDLIBS=`root-config --glibs`

$(EXEC): $(ALLSRC)
	$(CXX) $(CXXFLAGS) -W -Wall -g -o $@ $^ $(LDLIBS)

clean:
	rm -f $(EXEC) *.o

I must add that everything works fine if I’m using code produced by MakeSelector, the problem appears only when I want to compile “pure” C++ code.

Do you know what may be wrong here?

Kind regards,
Rafal

Hi,
I think that this erros is caused by virtual function i particle_event class that has been declared but not definded.
Cheers,
Daniel.

Hi,

thank you for your reply. Unfortunately, all functions are defined and none of them are virtual…

Regards,
Rafal

Try this … from your source code, remove the line:
gROOT->ProcessLine(".L particle_event.cxx+");
and use the following makefile: [code]ALLSRC=selector.C Expr.cpp Logical.cpp Eq.cpp Lt.cpp Gt.cpp And.cpp Or.cpp Cut.cpp EventSelector.cpp
EXEC=selector
CXX=root-config --cxx
CXXFLAGS=root-config --cflags
LDLIBS=root-config --glibs

$(EXEC): $(ALLSRC) particle_event.cxx
root -l -b -n -q particle_event.cxx++
$(CXX) $(CXXFLAGS) -W -Wall -g -o $@ $^ particle_event_cxx.so $(LDLIBS)

clean:
rm -f $(EXEC) *.o *.so[/code]