Linking clang on linux

I'm trying to get my project (which uses clang) to build on linux and I'm running into a unresolved symbol error while loading one of the modules:

undefined symbol: _ZN5clang11ASTConsumer21HandleInterestingDeclENS_12DeclGroupRefE

Searching for the symbol in the clang/LLVM libraries indicates the symbol resides in libclangAST.a:

./libclangAST.a
0000000000000000 T _ZN5clang11ASTConsumer21HandleInterestingDeclENS_12DeclGroupRefE

I'm already linking libclangAST.a into my project so I'm wondering what I'm missing or what the problem could be otherwise:

LLVMLIBS = libLLVMProfileData.a libLLVMCppBackendCodeGen.a libLLVMX86CodeGen.a libLLVMX86AsmParser.a libLLVMX86Disassembler.a libLLVMBitWriter.a libLLVMIRReader.a libLLVMInstrumentation.a libLLVMipo.a libLLVMLinker.a libLLVMCppBackendInfo.a libLLVMX86Desc.a libLLVMXCoreDesc.a libLLVMAsmParser.a libLLVMBitReader.a libLLVMVectorize.a libLLVMAsmPrinter.a libLLVMSelectionDAG.a libLLVMMipsAsmPrinter.a libLLVMMipsInfo.a libLLVMX86AsmPrinter.a libLLVMX86Info.a libLLVMMCParser.a libLLVMCodeGen.a libLLVMX86Utils.a libLLVMObjCARCOpts.a libLLVMScalarOpts.a libLLVMInstCombine.a libLLVMTransformUtils.a libLLVMipa.a libLLVMAnalysis.a libLLVMTarget.a libLLVMCore.a libLLVMMC.a libLLVMObject.a libLLVMSupport.a libclangFrontendTool.a libclangAST.a libclangAnalysis.a libclangBasic.a libclangCodeGen.a libclangDriver.a libclangEdit.a libclangFrontend.a libclangLex.a libclangParse.a libclangSema.a libclangSerialization.a libclangStaticAnalyzerFrontend.a libclangStaticAnalyzerCheckers.a libclangStaticAnalyzerCore.a libclangARCMigrate.a libclangRewriteCore.a libclangRewriteFrontend.a libLLVMOption.a

Thanks a lot

It sounds like the order of libraries passed to the linker is incorrect. The inputs have to be sorted topologically, where each library appears before all of its dependencies.

Alternatively you can use --start-group … --end-group to make it search out of order, but that shouldn’t be necessary.

It sounds like the order of libraries passed to the linker is incorrect.
The inputs have to be sorted topologically, where each library appears
before all of its dependencies.

Alternatively you can use --start-group ... --end-group to make it search
out of order, but that shouldn't be necessary.

I *think* there were circular deps that require specifying some libs
multiple times. FWIW, the Makefile in my LLVM & Clang samples repo (
https://github.com/eliben/llvm-clang-samples/blob/master/Makefile) uses
groups and it works great. It has proven much easier to maintain than
following Clang's library deps (that kept breaking every month or so :-/)

Eli