Problems with ClassDef()

Hi,

I have some really weird problems using ClassDef() in my custom class. I added the output of root-config --cflags --glibs to my compiler flags and without ClassDef() my code compiles fine.
Here is my code:
DatStruct.h:

[code]#ifndef DATSTRUCT
#define DATSTRUCT

#include “globals.h”
#include “fdac.h”
#include “Rtypes.h”

#define MAX_FADC 16 // up to 16 FADCs possible

class DatStruct
{
public:
unsigned long header; // separator word, always 0xffffffff
unsigned long eventcnt; // 32bit event counter, should match with 8bit FADC event number
unsigned char trg_time; // measured trigger time (raw format)
unsigned char subevents; // number of subevents found within this event
unsigned char number_apvs; // number of APVs in this run
unsigned char number_fadcs; // number of FADCs in this run
unsigned long fadcmode; // current mode (transparent, hit, hit+inputheaders)
unsigned long tlueventnumber; // TLU event number (was previously spare1)
unsigned long spare2; // reserved
unsigned short fadcdatalength[MAX_FADC]; // up to 16 FADCs possible

unsigned long fadc_rawdata[FADC_MODULES][MAX_FADC_DATA];
unsigned long fadc_rawdata_up[FADC_MODULES][MAX_FADC_DATA];
unsigned int fadc_num_rawdata[FADC_MODULES];

DatStruct();
DatStruct(const save_event_header* dat_header, unsigned long* dat_fadc_rawdata[][MAX_FADC_DATA], unsigned long* dat_fadc_rawdata_up[][MAX_FADC_DATA], unsigned int* dat_fadc_num_rawdata[]);
DatStruct(const DatStruct& other);
virtual ~DatStruct();


ClassDef(DatStruct,1); 

};

#endif // DATSTRUCT_H[/code]

DatStruct.cpp:

[code]#include “DatStruct.h”
#include “Rtypes.h”

//ClassImp(DatStruct)

/Constructor/
DatStruct::DatStruct() {
/save_event_header part/
this->header = 0; // separator word, always 0xffffffff
this->eventcnt = 0; // 32bit event counter, should match with 8bit FADC event number
this->trg_time = 0; // measured trigger time (raw format)
this->subevents = 0; // number of subevents found within this event
this->number_apvs = 0; // number of APVs in this run
this->number_fadcs = 0; // number of FADCs in this run
this->fadcmode = 0; // current mode (transparent, hit, hit+inputheaders)
this->tlueventnumber = 0; // TLU event number (was previously spare1)
this->spare2 = 0; // reserved
for (int i(0);i<MAX_FADC;i++) this->fadcdatalength[i] = 0; // up to 16 FADCs possible

/fdac.h part/
for (int i(0);i<FADC_MODULES;i++) {
for (int j(0);j<MAX_FADC_DATA;j++) this->fadc_rawdata[i][j] = 0;
}
for (int i(0);i<FADC_MODULES;i++) {
for (int j(0);j<MAX_FADC_DATA;j++) this->fadc_rawdata_up[i][j] = 0;
}
for (int i(0);i<FADC_MODULES;i++) this->fadc_num_rawdata[i] = 0;
}

/Constructor from combined data structur in .dat file/
DatStruct::DatStruct(const save_event_header* dat_header, unsigned long* dat_fadc_rawdata[][MAX_FADC_DATA], unsigned long* dat_fadc_rawdata_up[][MAX_FADC_DATA], unsigned int* dat_fadc_num_rawdata[]) {
this->header = dat_header->header; // separator word, always 0xffffffff
this->eventcnt = dat_header->eventcnt; // 32bit event counter, should match with 8bit FADC event number
this->trg_time = dat_header->trg_time; // measured trigger time (raw format)
this->subevents = dat_header->subevents; // number of subevents found within this event
this->number_apvs = dat_header->number_apvs; // number of APVs in this run
this->number_fadcs = dat_header->number_fadcs; // number of FADCs in this run
this->fadcmode = dat_header->fadcmode; // current mode (transparent, hit, hit+inputheaders)
this->tlueventnumber = dat_header->tlueventnumber; // TLU event number (was previously spare1)
this->spare2 = dat_header->spare2; // reserved
for (int i(0);i<MAX_FADC;i++) this->fadcdatalength[i] = dat_header->fadcdatalength[i]; // up to 16 FADCs possible

/fdac.h part/
for (int i(0);i<FADC_MODULES;i++) {
for (int j(0);j<MAX_FADC_DATA;j++) this->fadc_rawdata[i][j] = *dat_fadc_rawdata[i][j];
}
for (int i(0);i<FADC_MODULES;i++) {
for (int j(0);j<MAX_FADC_DATA;j++) this->fadc_rawdata_up[i][j] = *dat_fadc_rawdata_up[i][j];
}
for (int i(0);i<FADC_MODULES;i++) this->fadc_num_rawdata[i] = *dat_fadc_num_rawdata[i];
}

/Copy Constructor/
DatStruct::DatStruct(const DatStruct& other) {
this->header = other.header; // separator word, always 0xffffffff
this->eventcnt = other.eventcnt; // 32bit event counter, should match with 8bit FADC event number
this->trg_time = other.trg_time; // measured trigger time (raw format)
this->subevents = other.subevents; // number of subevents found within this event
this->number_apvs = other.number_apvs; // number of APVs in this run
this->number_fadcs = other.number_fadcs; // number of FADCs in this run
this->fadcmode = other.fadcmode; // current mode (transparent, hit, hit+inputheaders)
this->tlueventnumber = other.tlueventnumber; // TLU event number (was previously spare1)
this->spare2 = other.spare2; // reserved
for (int i(0);i<MAX_FADC;i++) this->fadcdatalength[i] = other.fadcdatalength[i]; // up to 16 FADCs possible

/fdac.h part/
for (int i(0);i<FADC_MODULES;i++) {
for (int j(0);j<MAX_FADC_DATA;j++) this->fadc_rawdata[i][j] = other.fadc_rawdata[i][j];
}
for (int i(0);i<FADC_MODULES;i++) {
for (int j(0);j<MAX_FADC_DATA;j++) this->fadc_rawdata_up[i][j] = other.fadc_rawdata_up[i][j];
}
for (int i(0);i<FADC_MODULES;i++) this->fadc_num_rawdata[i] = other.fadc_num_rawdata[i];
}

DatStruct::~DatStruct(){}[/code]

and here are the errors:

Linking CXX executable hat CMakeFiles/hat.dir/DatStruct.cpp.o: In function `DatStruct::IsA() const': /home/adonai/projects/hat/DatStruct.h:63: undefined reference to `DatStruct::Class()' CMakeFiles/hat.dir/DatStruct.cpp.o:(.rodata._ZTV9DatStruct[vtable for DatStruct]+0x14): undefined reference to `DatStruct::ShowMembers(TMemberInspector&, char*)' CMakeFiles/hat.dir/DatStruct.cpp.o:(.rodata._ZTV9DatStruct[vtable for DatStruct]+0x18): undefined reference to `DatStruct::Streamer(TBuffer&)' collect2: ld returned 1 exit status make[2]: *** [hat] Error 1 make[1]: *** [CMakeFiles/hat.dir/all] Error 2 make: *** [all] Error 2

Any help is much appreciated.

BR

Erik

Hi,

You need to generate (via rootcint), compile and link a dictionary for your class.

Philippe.

Hi,

Thank you! It worked.
For completeness here is what I did.
In the directory of my project I did:

rootcint -f DatStructDict.cpp -c DatStruct.h
then added DatStructDict.cpp to CMakeLists.txt

BR

Erik