[cfe-dev] Clang library documentation

Eli Friedman eli.friedman at gmail.com
Wed Apr 20 12:15:56 PDT 2011


On Wed, Apr 20, 2011 at 12:02 PM, Fletcher, John P
<j.p.fletcher at aston.ac.uk> wrote:
> Eli
>
> Thank you.
>
> I should explain my reason a bit more.  I wanted to document the version of Clang in my code.
> I found this was in the header clang/Basic/Version.h and put that into my code.
> I found a routine there called  getClangFullVersion() which I called in my code.
> I then need to link a library for it which is -lclangBasic but that is not enough.
> As well I need -lLLVMSupport -lpthread -ldl to avoid linker errors.
> All this I have found by trial and error.
>
> Is there documentation about which LLVM library does which to link a Clang program?

Ah.  For the clang libs, there aren't any docs, but roughly, if you
use a header from clang/Basic, you need libclangBasic.a, etc.  The
current complete list of clang libs used to build the clang
executable:

USEDLIBS = clangFrontendTool.a clangFrontend.a clangDriver.a \
           clangSerialization.a clangCodeGen.a clangParse.a clangSema.a \
           clangStaticAnalyzerFrontend.a clangStaticAnalyzerCheckers.a \
           clangStaticAnalyzerCore.a \
           clangAnalysis.a clangIndex.a clangRewrite.a \
           clangAST.a clangLex.a clangBasic.a

For the non-clang libs, there the very useful llvm-config program,
which figures out the necessary LLVM libs; use `llvm-config --ldflags`
to grab the basic link flags, plus `llvm-config --libs` to grab the
LLVM libraries (see http://llvm.org/cmds/llvm-config.html for the docs
for that).

-Eli




More information about the cfe-dev mailing list