New comer's problem: library link error of a clang example

Hi all,

I just started learning clang example. I tried to build an example (as
attached .cpp and Makefile), and get the following link errors:

/nfs/susangao/llvm-root/my-example/clang/tut/test.cpp:30: undefined
reference to `clang::CompilerInstance::CompilerInsta
http://clang-developers.42468.n3.nabble.com/file/n3532706/test.tar.gz
test.tar.gz nce()'
/nfs/susangao/llvm-root/my-example/clang/tut/test.cpp:33: undefined
reference to `clang::CompilerInstance::createDiagnostics(int, char const*
const*, clang::DiagnosticConsumer*, bool, bool)'
/nfs/susangao/llvm-root/my-example/clang/tut/test.cpp:35: undefined
reference to
`clang::CompilerInvocation::CreateFromArgs(clang::CompilerInvocation&, char
const* const*, char const* const*, clang::DiagnosticsEngine&)'
/nfs/susangao/llvm-root/my-example/clang/tut/test.cpp:37: undefined
reference to `clang::TargetInfo::CreateTargetInfo(clang::DiagnosticsEngine&,
clang::TargetOptions&)'
/nfs/susangao/llvm-root/my-example/clang/tut/test.cpp:37: undefined
reference to `clang::CompilerInstance::setTarget(clang::TargetInfo*)'
/nfs/susangao/llvm-root/my-example/clang/tut/test.cpp:39: undefined
reference to `clang::CompilerInstance::createFileManager()'
/nfs/susangao/llvm-root/my-example/clang/tut/test.cpp:40: undefined
reference to
`clang::CompilerInstance::createSourceManager(clang::FileManager&)'
/nfs/susangao/llvm-root/my-example/clang/tut/test.cpp:41: undefined
reference to `clang::CompilerInstance::createPreprocessor()'
/nfs/susangao/llvm-root/my-example/clang/tut/test.cpp:42: undefined
reference to `clang::CompilerInstance::createASTContext()'
/nfs/susangao/llvm-root/my-example/clang/tut/test.cpp:43: undefined
reference to `clang::CompilerInstance::setASTConsumer(clang::ASTConsumer*)'
/nfs/susangao/llvm-root/my-example/clang/tut/test.cpp:45: undefined
reference to
`clang::CompilerInstance::createSema(clang::TranslationUnitKind,
clang::CodeCompleteConsumer*)'
/nfs/susangao/llvm-root/my-example/clang/tut/test.cpp:47: undefined
reference to
`clang::CompilerInstance::InitializeSourceManager(llvm::StringRef)'
/nfs/susangao/llvm-root/my-example/clang/tut/test.cpp:48: undefined
reference to `clang::ParseAST(clang::Preprocessor&, clang::ASTConsumer*,
clang::ASTContext&, bool, clang::TranslationUnitKind,
clang::CodeCompleteConsumer*)'
/nfs/susangao/llvm-root/my-example/clang/tut/test.cpp:50: undefined
reference to `clang::CompilerInstance::~CompilerInstance()'
/tmp/ccqBn324.o: In function `ASTConsumer':
/nfs/susangao/llvm-root/llvm/tools/clang/include/clang/AST/ASTConsumer.h:39:
undefined reference to `vtable for clang::ASTConsumer'
/tmp/ccqBn324.o: In function `~ASTConsumer':
/nfs/susangao/llvm-root/llvm/tools/clang/include/clang/AST/ASTConsumer.h:41:
undefined reference to `vtable for clang::ASTConsumer'
/tmp/ccqBn324.o: In function
`llvm::raw_ostream::operator<<(llvm::StringRef)':
/nfs/susangao/llvm-root/llvm/include/llvm/Support/raw_ostream.h:160:
undefined reference to `llvm::raw_ostream::write(char const*, unsigned
long)'
/tmp/ccqBn324.o: In function
`llvm::raw_ostream::operator<<(std::basic_string<char,
std::char_traits&lt;char>, std::allocator<char> > const&)':
/nfs/susangao/llvm-root/llvm/include/llvm/Support/raw_ostream.h:176:
undefined reference to `llvm::raw_ostream::write(char const*, unsigned
long)'
/tmp/ccqBn324.o: In function `clang::NamedDecl::getNameAsString() const':
/nfs/susangao/llvm-root/llvm/tools/clang/include/clang/AST/Decl.h:135:
undefined reference to `clang::DeclarationName::getAsString() const'
/tmp/ccqBn324.o: In function
`PrintFunctionsConsumer::HandleTopLevelDecl(clang::DeclGroupRef)':
/nfs/susangao/llvm-root/my-example/clang/tut/test.cpp:21: undefined
reference to `llvm::errs()'
/tmp/ccqBn324.o:(.data.rel.ro._ZTV22PrintFunctionsConsumer[vtable for
PrintFunctionsConsumer]+0x30): undefined reference to
`clang::ASTConsumer::HandleInterestingDecl(clang::DeclGroupRef)'
/tmp/ccqBn324.o:(.data.rel.ro._ZTV22PrintFunctionsConsumer[vtable for
PrintFunctionsConsumer]+0x48): undefined reference to
`clang::ASTConsumer::HandleTopLevelDeclInObjCContainer(clang::DeclGroupRef)'
collect2: ld returned 1 exit status
make: *** [all] Error 1

Would you please help me to know what causes this link error?

The code of llvm and clang are checked out from trunk.

APPRECIATE!

Susan