[cfe-dev] Linking options

Paolo Bolzoni bolzoni at cs.unipr.it
Wed May 28 04:52:09 PDT 2008


Here a very simple program, t.cc:

#include <clang/Basic/SourceManager.h>

int main(int argc, char** argv) {
  using namespace clang;
  SourceManager source_mgr;

}

Compiling command (taken almost one-to-one from clang executable linking):
g++ -o /dev/null \
t.cc \
-lclangCodeGen \
-lclangAnalysis \
-lclangRewrite \
-lclangSEMA \
-lclangAST \
-lclangParse \
-lclangLex \
-lclangBasic \
-lLLVMCore \
-lLLVMSupport \
-lLLVMSystem \
-lLLVMBitWriter \
-lLLVMBitReader \
-lLLVMCodeGen \
-lLLVMTarget \
-lpthread \
-ldl \
-lm \
-lelf

Result:
/usr/lib/gcc/x86_64-unknown-linux-gnu/4.3.0/../../../../lib/libLLVMBitReader.a(Deserialize.o):
In function `llvm::Deserializer::~Deserializer()':
Deserialize.cpp:(.text+0xe1): undefined reference to
`llvm::BumpPtrAllocator::~BumpPtrAllocator()' /usr/lib/gcc/x86_64-unknown-linux-gnu/4.3.0/../../../../lib/libLLVMBitReader.a(Deserialize.o):
In function `llvm::Deserializer::~Deserializer()':
Deserialize.cpp:(.text+0x181): undefined reference to
`llvm::BumpPtrAllocator::~BumpPtrAllocator()' /usr/lib/gcc/x86_64-unknown-linux-gnu/4.3.0/../../../../lib/libLLVMBitReader.a(Deserialize.o):
In function `llvm::Deserializer::Deserializer(llvm::BitstreamReader&)':
Deserialize.cpp:(.text+0x20c): undefined reference to
`llvm::BumpPtrAllocator::BumpPtrAllocator()' /usr/lib/gcc/x86_64-unknown-linux-gnu/4.3.0/../../../../lib/libLLVMBitReader.a(Deserialize.o):
In function `llvm::Deserializer::Deserializer(llvm::BitstreamReader&)':
Deserialize.cpp:(.text+0x300): undefined reference to
`llvm::BumpPtrAllocator::BumpPtrAllocator()' /usr/lib/gcc/x86_64-unknown-linux-gnu/4.3.0/../../../../lib/libLLVMBitReader.a(Deserialize.o):
In function `llvm::Deserializer::ReadUIntPtr(unsigned long&, unsigned int
const&, bool)': Deserialize.cpp:(.text+0x9bb): undefined reference to
`llvm::BumpPtrAllocator::Allocate(unsigned long, unsigned long)' collect2: ld
returned 1 exit status

What am I doing wrong?



More information about the cfe-dev mailing list