Vtable undefined reference

Dear all,
I have a class using some enum structure, like:

typedef enum a {
x1=0,
x2=2
} a;

class LRCConfigV1718Pulser: public TObject {


private:
a x;

};

I make the dictionary of the class through rootcint:

#pragma link C++ class LRCConfigV1718Pulser+;

At the linking phase, I have the following output:

main/runServer.C:301: warning: deprecated conversion from string constant to ‘char*’
g+±4.2 -I/cern/root/include -Igui -Iacq -Icomm -Isys -Icfg -Iled -Wall -g -ansi -DLINUX -lm -pthread -m32 -I/cern/root/include -L/cern/root/lib -lCore -lCint -lRIO -lNet -lHist -lGraf -lGraf3d -lGpad -lTree -lRint -lPostscript -lMatrix -lPhysics -lMathCore -lThread -pthread -lm -ldl -rdynamic -L/cern/root/lib -lCore -lCint -lRIO -lNet -lHist -lGraf -lGraf3d -lGpad -lTree -lRint -lPostscript -lMatrix -lPhysics -lMathCore -lThread -lGui -pthread -lm -ldl -rdynamic -LCAENVME/lib -lCAENVME bin/runServer.o -L./libs -lacq -lcfg -lsys -lcom -o bin/runServer.exe
./libs/libcfg.a(LRCConfigV1718Pulser.o): In function LRCConfigV1718Pulser': /home/barao/ROOT/GUI.work/LRC/cfg/LRCConfigV1718Pulser.C:16: undefined reference tovtable for LRCConfigV1718Pulser’
/home/barao/ROOT/GUI.work/LRC/cfg/LRCConfigV1718Pulser.C:16: undefined reference to vtable for LRCConfigV1718Pulser' ./libs/libcfg.a(LRCConfigV1718Pulser_Dict.o): In functionROOT::GenerateInitInstanceLocal(LRCConfigV1718Pulser const*)’:
/home/barao/ROOT/GUI.work/LRC/tmp/LRCConfigV1718Pulser_Dict.C:55: undefined reference to typeinfo for LRCConfigV1718Pulser' ./libs/libcfg.a(LRCConfigV1718Pulser_Dict.o): In functionLRCConfigV1718Pulser’:
/home/barao/ROOT/GUI.work/LRC/cfg/LRCConfigV1718Pulser.h:13: undefined reference to `vtable for LRCConfigV1718Pulser’
collect2: ld returned 1 exit status


Has anyone an idea of what is causing this?
Should the enum structures be included into the LinkDef.h file?

Many thanks in advance.

Add the following pragma

#pragma link C++ enum a;
Rene

[quote=“brun”]Add the following pragma

#pragma link C++ enum a;
Rene[/quote]

Thanks for the quick reply.
UNfortunately I had tried it already. I mean, I have several typedefs and I had added in the same LinkDef.h (of the class I’m doing the I/O) lines like the one you ate telling me, with the different enum names.
But the problem still remained…Sorry!

thanks again.

Your problem does not seem to be connected with enums, but rather with a class declared in the header file and not implemented. Could you post the smallest possible setup reproducing your problem?

Rene

Hi,

Usually this happens when you do not provide an implemented for the ‘first’ virtual function of the class (and/or the destructor).

Cheers,
Philippe

[quote=“pcanal”]Hi,

Usually this happens when you do not provide an implemented for the ‘first’ virtual function of the class (and/or the destructor).

Cheers,
Philippe[/quote]

That was the solution…the destructor had no explicit code.
Therefore, and being useful for others with the same dought, I conclude that any user class added to root shall have explicitily the code for the constructor and destructor.
Thanks again.

[quote] I conclude that any user class added to root shall have explicitily the code for the constructor and destructor.[/quote]The rule is even more general :slight_smile: … any class that you intend to use in any C++ program should have code for these methods … and probably for any explicit declared public methods (since they might be called by any user of your class ! :slight_smile:.

Cheers,
Philippe.