[cfe-dev] Cannot compile program when using the AnalysisManager

Munawar Hafiz munawar.hafiz at gmail.com
Sun Dec 12 19:21:50 PST 2010


Hi,
I am new to clang. I was trying to invoke the AnalysisManager object and use
it in a program. I am quoting relevant parts of the code.


CXIndex index = clang_createIndex(1, 0);
CXTranslationUnit tu = clang_createTranslationUnitFromSourceFile(index,
            "simple.c", 0, 0x0, 0, 0x0);
ASTUnit *astUnit = static_cast<ASTUnit *> (tu);
Preprocessor &pe = astUnit->getPreprocessor();
AnalysisManager AMgr(astUnit->getASTContext(), pe.getDiagnostics(),
                           pe.getLangOptions(), 0,
                           0,
                           0, &Idxer,
                           /* MaxNodes */ 300, /* MaxVisit */ 3,
                           /* VisualizeEG */ false, /* VisualizeEGUbi */
false,
                           /* PurgeDead */ true, /* EagerlyAssume */ false,
                           /* TrimGraph */ false, /* InlineCall */ true,
                           /* UseUnoptimizedCFG */ false, false, false);



Now, I am compiling the program with the following command.

g++ -O2 -g -Wall -fmessage-length=0 -D __STDC_LIMIT_MACROS=1 -D
__STDC_CONSTANT_MACROS=1
-I/home/munawar/install/llvm/tools/clang/tools/libclang  -o llvmTest
llvmTest.o
/home/munawar/install/llvm_build/tools/clang/tools/libclang/Release+Asserts/CIndex.o
/home/munawar/install/llvm_build/tools/clang/tools/libclang/Release+Asserts/CXCursor.o
/home/munawar/install/llvm_build/tools/clang/tools/libclang/Release+Asserts/CXType.o
/home/munawar/install/llvm_build/tools/clang/tools/libclang/Release+Asserts/CIndexer.o
/home/munawar/install/llvm_build/tools/clang/tools/libclang/Release+Asserts/CIndexDiagnostic.o
/home/munawar/install/llvm_build/tools/clang/tools/libclang/Release+Asserts/CIndexUSRs.o
-lclangIndex -lclangChecker  -lclangFrontend -lclangSema -lclangLex
-lclangParse  -lclangDriver  -lclangAnalysis    -lclangSerialization
-lclangAST -lclangBasic -lLLVMMC  -lLLVMCore -lLLVMSupport -lLLVMSystem
-lpthread -ldl

The interesting and probably relevant part is the library sequence.

-lclangIndex -lclangChecker  -lclangFrontend -lclangSema -lclangLex
-lclangParse  -lclangDriver  -lclangAnalysis    -lclangSerialization
-lclangAST -lclangBasic -lLLVMMC  -lLLVMCore -lLLVMSupport -lLLVMSystem
-lpthread -ldl

But I am getting this error,

llvmTest.o:(.rodata._ZTIN5clang15AnalysisManagerE[typeinfo for
clang::AnalysisManager]+0x8): undefined reference to `typeinfo for
clang::BugReporterData'
collect2: ld returned 1 exit status

Can you please point out where I am making a mistake ? Thanks.


Munawar
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20101212/a6a9c0ac/attachment.html>


More information about the cfe-dev mailing list