Re: building classes into root.

From: Fons Rademakers (rdm)
Date: Tue Dec 23 1997 - 11:14:17 MET


Hi Steve,

   make sure that each class definition contains the ClassDef macro, e.g.
ClassDef(hit,1)

and that each implementation file contains the ClassImp macro:

ClassImp(hit)

Further each class that wants to do I/O needs a default constructor, e.g.:

hit::hit() { ... }

Check carefully the Event example and read the web pages starting at
http://root.cern.ch/root/Using.html

If problems persist send me privately the header that causes the problems.
Or check with local FNAL ROOT gure Pasha Murat.

Cheers, Fons.


> 
> 
> Hi,
> 
> I am trying to build a class into root. I am running on Linux, root 1.03/06.
> 
> The event class is called "event" and it has a "hit" object as a member.
> This is analogous to the example in the test directory in the distribution.
> 
> I find that i must put the headers for both classes in the same file,
> and also i must put the event.cc and hit.cc files together.
> 
> If i don't, i get compilation errors like:
> 
> eventDict.o: In function `G__hit_hit_0_0__FP8G__valuePcP8G__parami':
> eventDict.o(.text+0xef): undefined reference to `hit::hit(void)'
> eventDict.o(.text+0x13e): undefined reference to `hit::hit(void)'
> eventDict.o: In function `G__hit_read_1_0__FP8G__valuePcP8G__parami':
> eventDict.o(.text+0x1e4): undefined reference to `hit::read(int)'
> eventDict.o: In function `G__hit_ImplFileName_4_0__FP8G__valuePcP8G__parami':
> eventDict.o(.text+0x2b1): undefined reference to `hit::ImplFileName(void)'
> eventDict.o: In function `G__hit_ImplFileLine_5_0__FP8G__valuePcP8G__parami':
> eventDict.o(.text+0x2f1): undefined reference to `hit::ImplFileLine(void)'
> eventDict.o: In function `G__hit_Class_7_0__FP8G__valuePcP8G__parami':
> eventDict.o(.text+0x371): undefined reference to `hit::Class(void)'
> eventDict.o: In function `G__hit_Dictionary_8_0__FP8G__valuePcP8G__parami':
> eventDict.o(.text+0x3bd): undefined reference to `hit::Dictionary(void)'
> eventDict.o: In function `operator>>(TBuffer &, hit *&)':
> eventDict.o(.text+0x1f52): undefined reference to `hit::Class(void)'
> eventDict.o: In function `hit::IsA(void) const':
> eventDict.o(.text+0x2555): undefined reference to `hit::Class(void)'
> /tmp/cca008011.o: In function `event::event(void)':
> /home/eichblat/root-macro/treeTest/mcEvents/event.cc:9: undefined reference to `hit::hit(void)'
> 
> I am making the eventDict files with the following command:
> 
> eventDict.cc : event.cc event.h LinkDef.h
>         $(ROOTCINT) -f $@ -c event.h hit.h LinkDef.h
> 
> where LinkDef.h says :
> 
> #ifdef __CINT__
> 
> #pragma link off all globals;
> #pragma link off all classes;
> #pragma link off all functions;
> 
> #pragma link C++ class hit;
> #pragma link C++ class event;
> 
> #endif
> 
> I really don't know what i am doing, but i would like to separate the source
> code into separate files. Any help would be appreciated. 
> 
> Thanks!
> 
> Steve Eichblatt
> eichblatt@fnal.gov
> 


-- 
Org:    CERN, European Laboratory for Particle Physics.
Mail:   1211 Geneve 23, Switzerland          Phone: +41 22 7679248
E-Mail: Fons.Rademakers@cern.ch              Fax:   +41 22 7677910



This archive was generated by hypermail 2b29 : Tue Jan 04 2000 - 00:26:23 MET