[cfe-users] linker errors against clang/llvm libraries

Adrian Ortega elfus0.1 at gmail.com
Wed Feb 12 21:03:52 PST 2014

On 11/02/14 03:28, Dmitri Gribenko wrote:
> On Tue, Feb 11, 2014 at 4:15 AM, Adrian Ortega <elfus0.1 at gmail.com> wrote:
>> $> clang++ `llvm-config --ldflags` main.o `llvm-config --libs`
>> It fails with the following output (I just put the first error to not
>> clutter this post):
>> main.o: In function `main':
>> main.cpp:74: undefined reference to `clang::TextDiagnosticPrinter::Text!
> I'm afraid llvm-config does not know anything about clang libraries,
> they need to be added separately.  Alternatively, it would be nice if
> we had clang-config (or a similar utility).
> Dmitri
I looked at an example from the Makefiles clang/tools, and the final 
command line was

clang++ `llvm-config --ldflags` main.o  -lclangFrontendTool 
-lclangFrontend -lclangDriver -lclangSerialization -lclangCodeGen 
-lclangParse -lclangSema -lclangStaticAnalyzerFrontend 
-lclangStaticAnalyzerCheckers -lclangStaticAnalyzerCore -lclangAnalysis 
-lclangARCMigrate -lclangRewriteFrontend -lclangRewriteCore -lclangEdit 
-lclangAST -lclangLex -lclangBasic `llvm-config --libs`

Now it compiles :)

Such a silly mistake, but I appreciate your response, it made me see my 


More information about the cfe-users mailing list