undefined reference to typeinfo for clang::ASTFrontendAction

Hello cfe-dev,

trying to compile this simple code, but somehow it doesnt work. Can
somebody point me to what i'm missing.


#include <clang/Frontend/CompilerInstance.h>
#include <clang/Frontend/FrontendAction.h>

class MyASTAction: public clang::ASTFrontendAction {
       virtual clang::ASTConsumer*
CreateASTConsumer(clang::CompilerInstance &CI,
                       llvm::StringRef InFile) {
               return 0;


int main(int argc, const char** argv) {
       MyASTAction action;

       return 0;

**** Build of configuration Debug for project clangtest ****

make all
Building file: ../main.cpp
Invoking: GCC C++ Compiler
g++ -I/home/dima/Software/llvm-2.8/include -O0 -g3 -Wall -c
-fmessage-length=0 -MMD -MP -MF"main.d" -MT"main.d" -o"main.o"
Finished building: ../main.cpp

Building target: clangtest
Invoking: GCC C++ Linker
g++ -L/home/dima/Software/llvm-2.8-dbg/lib -o"clangtest" ./main.o
-lclangFrontend -lclangSerialization -lclangDriver -lclangCodeGen
-lclangSema -lclangChecker -lclangAnalysis -lclangRewrite -lclangAST
-lclangParse -lclangLex -lclangBasic -lLLVMMC -lLLVMCore -lLLVMSupport
-lLLVMSystem -lpthread -ldl -lm
./main.o:(.rodata._ZTI11MyASTAction[typeinfo for MyASTAction]+0x10):
undefined reference to `typeinfo for clang::ASTFrontendAction'
collect2: ld returned 1 exit status
make: *** [clangtest] Fehler 1

The ASTFrontendAction class derives from FrontendAction, which has several pure virtual functions. Are you sure you have overridden all of them?


If i wouldn't then the compiler would say me, that it
can't instantiate an abstract class. But this is a linker error and i
dont know, what
i'm missing.

Hello again,

looks like i found what i was missing. I must compile with
the -fno-rtti option.