[cfe-dev] help needed in compiling tutorial example

Nobin Mathew nobin.mathew at gmail.com
Wed Jun 16 08:50:31 PDT 2010


Thanks a lot,

This worked for me

g++ tut01_pp.cpp -g -fno-rtti -lclangDriver -lclangAnalysis
-lclangFrontend -lclangSema -lclangAST -lclangParse -lclangLex
-lclangBasic -I/home/nmathew/Desktop/llvm_work/llvm/tools/clang/include/
`/home/nmathew/Desktop/llvm_work/llvm/Debug/bin/llvm-config --cxxflags
--ldflags --libs`

But this gives errors

g++ -g -fno-rtti -lclangDriver -lclangAnalysis -lclangFrontend
-lclangSema -lclangAST -lclangParse -lclangLex -lclangBasic
-I/home/nmathew/Desktop/llvm_work/llvm/tools/clang/include/
`/home/nmathew/Desktop/llvm_work/llvm/Debug/bin/llvm-config --cxxflags
--ldflags --libs` tut01_pp.cpp

/tmp/ccTgoghe.o: In function `SourceManager':
/home/nmathew/Desktop/llvm_work/llvm/tools/clang/include/clang/Basic/SourceManager.h:409:
undefined reference to `llvm::BumpPtrAllocator::DefaultSlabAllocator'
/home/nmathew/Desktop/llvm_work/llvm/tools/clang/include/clang/Basic/SourceManager.h:409:
undefined reference to
`llvm::BumpPtrAllocator::BumpPtrAllocator(unsigned int, unsigned int,
llvm::SlabAllocator&)'
/home/nmathew/Desktop/llvm_work/llvm/tools/clang/include/clang/Basic/SourceManager.h:410:
undefined reference to `clang::SourceManager::clearIDTables()'
/tmp/ccTgoghe.o: In function `PPContext':
/home/nmathew/Desktop/cppscope/PPContext.h:97: undefined reference to
`llvm::errs()'
/home/nmathew/Desktop/cppscope/PPContext.h:97: undefined reference to
`clang::TextDiagnosticPrinter::TextDiagnosticPrinter(llvm::raw_ostream&,
clang::DiagnosticOptions const&, bool)'
/home/nmathew/Desktop/cppscope/PPContext.h:97: undefined reference to
`clang::Diagnostic::Diagnostic(clang::DiagnosticClient*)'
/home/nmathew/Desktop/cppscope/PPContext.h:97: undefined reference to
`clang::FileManager::FileManager()'
/home/nmathew/Desktop/cppscope/PPContext.h:97: undefined reference to
`clang::HeaderSearch::HeaderSearch(clang::FileManager&)'
/home/nmathew/Desktop/cppscope/PPContext.h:110: undefined reference to
`clang::TargetInfo::CreateTargetInfo(clang::Diagnostic&,
clang::TargetOptions&)'
/home/nmathew/Desktop/cppscope/PPContext.h:112: undefined reference to
`clang::Preprocessor::Preprocessor(clang::Diagnostic&,
clang::LangOptions const&, clang::TargetInfo const&,
clang::SourceManager&, clang::HeaderSearch&,
clang::IdentifierInfoLookup*, bool)'
/tmp/ccTgoghe.o: In function `~PPContext':
/home/nmathew/Desktop/cppscope/PPContext.h:119: undefined reference to
`clang::Preprocessor::~Preprocessor()'
/home/nmathew/Desktop/cppscope/PPContext.h:120: undefined reference to
`clang::HeaderSearch::~HeaderSearch()'
/home/nmathew/Desktop/cppscope/PPContext.h:120: undefined reference to
`clang::FileManager::~FileManager()'
/home/nmathew/Desktop/cppscope/PPContext.h:120: undefined reference to
`clang::SourceManager::~SourceManager()'
/home/nmathew/Desktop/cppscope/PPContext.h:120: undefined reference to
`clang::Diagnostic::~Diagnostic()'
collect2: ld returned 1 exit status

what is the difference here.

Thanks
Nobin

On Wed, Jun 16, 2010 at 2:02 PM, Sebastian Redl
<sebastian.redl at getdesigned.at> wrote:
>
> On Wed, 16 Jun 2010 10:36:57 +0530, Nobin Mathew <nobin.mathew at gmail.com>
> wrote:
>> Hi,
>>
>> I am having a compilation issue with tutorial example, please give me
>> some directions.
>>
>> hash#g++ `/home/nmathew/Desktop/llvm_work/llvm/Debug/bin/llvm-config
>> --ldflags` -lLLVMSupport -lLLVMSystem -lLLVMBitReader -lLLVMBitWriter
>> -lclangBasic -lclangLex -lclangDriver -lclangIndex -lclangFrontend
>> -lclangDriver -lclangSema -lclangAnalysis -lclangAST -lclangParse -o
>> tut01 tut01_pp.o
>
> Where is this tutorial from? The problem here is the command line.
> Libraries in *nix systems must be listed in reverse dependency order, i.e.
> first a library, then the libraries it depends on. So the llvm-config
> invocation must be last, all explicit llvm library directives should be
> removed in favor of appropriate llvm-config arguments (it ensures correct
> ordering), and the Clang libraries must be correctly ordered and come
> before the LLVM stuff.
>
> An order that ought to work for Clang is Driver, Frontend, Analysis,
> Index, Sema, AST, Parse, Lex, Basic, although recent trunk changes have
> changed the dependencies between Frontend and some other modules.
>
> We *really* need a clang-config tool or teach llvm-config to deal with
> Clang libraries.
>
> Sebastian
>



More information about the cfe-dev mailing list