Errors building clang plugin on Max OS

Hello everyone,
I am working on a clang plugin to translate c++ source code. It can be built
on Ubuntu OS without any problems. But when I tried to build it on Mac OS.
It output error messages:
llvm[0]: Compiling SourceCodexlate.cpp for Debug+Asserts build (PIC)
SourceCodexlate.cpp: In member function ‘void
rtssf::SourceCodexlateConsumer::RewriteProcedureDeclare(rtssf::Function*)’:
SourceCodexlate.cpp:451: warning: suggest a space before ‘;’ or explicit
braces around empty body in ‘while’ statement
SourceCodexlate.cpp:456: warning: suggest a space before ‘;’ or explicit
braces around empty body in ‘while’ statement
SourceCodexlate.cpp: In member function ‘void
rtssf::SourceCodexlateConsumer::RewriteProcedureDefine(rtssf::Function*)’:
SourceCodexlate.cpp:587: warning: suggest a space before ‘;’ or explicit
braces around empty body in ‘while’ statement
SourceCodexlate.cpp:648: warning: suggest a space before ‘;’ or explicit
braces around empty body in ‘while’ statement
SourceCodexlate.cpp: In member function ‘void
rtssf::SourceCodexlateConsumer::RewriteFunctionBody(clang::Stmt*,
rtssf::Function*, int&)’:
SourceCodexlate.cpp:773: warning: suggest a space before ‘;’ or explicit
braces around empty body in ‘while’ statement
SourceCodexlate.cpp:799: warning: suggest a space before ‘;’ or explicit
braces around empty body in ‘while’ statement
SourceCodexlate.cpp:800: warning: suggest a space before ‘;’ or explicit
braces around empty body in ‘while’ statement
llvm[0]: Linking Debug+Asserts Shared Library libSourceCodexlate.dylib
Undefined symbols:
  "llvm::APInt::initSlowCase(llvm::APInt const&)", referenced from:
      llvm::APInt::APInt(llvm::APInt const&)in SourceCodexlate.o
  "clang::FrontendAction::FrontendAction()", referenced from:
      clang::ASTFrontendAction::ASTFrontendAction()in SourceCodexlate.o
  "clang::SourceManager::getFileCharacteristic(clang::SourceLocation)
const", referenced from:
      clang::SourceManager::isInSystemHeader(clang::SourceLocation) constin
SourceCodexlate.o
      clang::SourceManager::isInExternCSystemHeader(clang::SourceLocation)
constin SourceCodexlate.o
  "clang::ASTConsumer::HandleTopLevelDecl(clang::DeclGroupRef)", referenced
from:
      vtable for rtssf::SourceCodexlateConsumerin SourceCodexlate.o
  "clang::FrontendAction::~FrontendAction()", referenced from:
      clang::ASTFrontendAction::~ASTFrontendAction()in SourceCodexlate.o
  "clang::DeclarationName::getAsString() const", referenced from:
      clang::NamedDecl::getNameAsString() constin SourceCodexlate.o
  "vtable for clang::ASTFrontendAction", referenced from:
   ::~ASTFrontendAction()in SourceCodexlate.o
      clang::ASTFrontendAction::ASTFrontendAction()in SourceCodexlate.o
  "clang::StmtIteratorBase::NextVA()", referenced from:
      clang::StmtIteratorImpl::operator++()in SourceCodexlate.o
      clang::StmtIteratorImpl::operator++()in SourceCodexlate.o
...
   clang::ld: symbol(s) not found
collect2: ld returned 1 exit status
make: ***
[/Users/ZQ/project/xlate/llvm/Debug+Asserts/lib/libSourceCodexlate.dylib]
Error 1
How could I fix these undefined errors? Any suggestion is appreciated.
Hao Jiang

You're probably listing your libraries in the wrong order. How do you
build your plugin? Does running `make` in
llvm/tools/clang/examples/PrintFunctionNames work for you? If so, you
might want to consider reusing that makefile.

Nico

Thank you for replying.
I did reuse makefile of PrintFunctionNames for my plugin and I used cd
llvm/tools/clang/examples/SourceCodexlate && make to build my plugin.
Strange thing is PrintFunctionNames work well on Mac. But my plugin reports
lots of undefined symbols, so I could not figure out what the problem is.
Hao Jiang