Wednesday, 11 September 2013

Trouble compiling code for doing source transformation in clang

Trouble compiling code for doing source transformation in clang

I've been working through a tutorial on C source code transformation in
clang(http://eli.thegreenplace.net/2012/06/08/basic-source-to-source-transformation-with-clang/),
but attempting to compile the code fails with many of the following
"undefined reference" errors:
g++ rewritersample.cpp -fno-rtti -o rewritersample \
-I/home/anirudh/source/cpptest_distrib/cpp/compiler_testing/tso-emulator/llvm/llvm-3.2/tools/clang/include
-I/home/anirudh/local/llvm/tools/clang/include -lclangTooling
-lclangFrontendTool -lclangFrontend -lclangDriver -lclangSerialization
-lclangCodeGen -lclangParse -lclangSema -lclangStaticAnalyzerFrontend
-lclangStaticAnalyzerCheckers -lclangStaticAnalyzerCore -lclangAnalysis
-lclangARCMigrate -lclangRewriteFrontend -lclangRewriteCore -lclangEdit
-lclangAST -lclangLex -lclangBasic
/home/anirudh/local/llvm/bin/llvm-config --cxxflags --ldflags --libs core
mc /home/anirudh/local/llvm/lib/libclangSema.a(SemaStmtAsm.cpp.o): In
function (anonymous
namespace)::MCAsmParserSemaCallbackImpl::~MCAsmParserSemaCallbackImpl()':
SemaStmtAsm.cpp:(.text+0x1fd2): undefined reference
tollvm::MCAsmParserSemaCallback::~MCAsmParserSemaCallback()'
/home/anirudh/local/llvm/lib/libclangSema.a(SemaStmtAsm.cpp.o): In
function clang::Sema::ActOnMSAsmStmt(clang::SourceLocation,
clang::SourceLocation, llvm::ArrayRef<clang::Token>,
clang::SourceLocation)': SemaStmtAsm.cpp:(.text+0x2f56): undefined
reference tollvm::createMCAsmParser(llvm::SourceMgr&, llvm::MCContext&,
llvm::MCStreamer&, llvm::MCAsmInfo const&)'
SemaStmtAsm.cpp:(.text+0x307c): undefined reference to
llvm::MCAsmParser::setTargetParser(llvm::MCTargetAsmParser&)'
/home/anirudh/local/llvm/lib/libclangSema.a(SemaStmtAsm.cpp.o): In
functionllvm::MCAsmParserSemaCallback::MCAsmParserSemaCallback()':
SemaStmtAsm.cpp:(.text._ZN4llvm23MCAsmParserSemaCallbackC2Ev[_ZN4llvm23MCAsmParserSemaCallbackC5Ev]+0xf):
undefined reference to vtable for llvm::MCAsmParserSemaCallback'
/home/anirudh/local/llvm/lib/libLLVMSupport.a(Signals.cpp.o): In
functionPrintStackTrace(void*)': Signals.cpp:(.text+0x6df): undefined
reference to dladdr' Signals.cpp:(.text+0x774): undefined reference
todladdr' collect2: error: ld returned 1 exit status make: *
[rewritersample] Error 1
Does anybody have any idea on how to resolve these errors?

No comments:

Post a Comment