Problems in clang/AST/ASTConsumer.h

I'm extending the ASTConsumer class to make some custom analysis on the Syntax tree created by clang in the following way:

class MyASTConsumer: public ASTConsumer {

when I try to compile my program using the g++ compiler (I've used both the gcc 3.4.6 and gcc 4.3.2). I get the following error:

build/main.o(.gnu.linkonce.r._ZTI13MyASTConsumer+0x10): undefined reference to `typeinfo for clang::ASTConsumer'
collect2: ld returned 1 exit status

Apparently the error is caused by the empty virtual definition of ASTConsumer methods:
virtual ~ASTConsumer();
virtual void InitializeTU(TranslationUnit& TU) ;

changing this declaration (in the ASTConsumer.h file) into:
virtual ~ASTConsumer() {}
virtual void InitializeTU(TranslationUnit& TU) {}
virtual ~ASTConsumer() = 0;
virtual void InitializeTU(TranslationUnit& TU) = 0;

fixes the problem for me! Of course in the second problem I have to provide an implementation for both the methods in my class.

I hope it helps,
greetings Simone

did you use -fno-rtti?

Paolo Bolzoni wrote:

did you use -fno-rtti?

No, using the -fno-rtti flags fixes the problem!