[cfe-users] link order for libtooling
Mikhail Ramalho via cfe-users
cfe-users at lists.llvm.org
Thu Jul 14 07:38:41 PDT 2016
In ESBMC [0], we use:
-lclangTooling -lclangDriver -lclangFrontend -lclangParse
-lclangSerialization -lclangSema -lclangAnalysis -lclangEdit -lclangLex
-lclangAST -lclangBasic -lLLVMBitReader -lLLVMCore -lLLVMOption
-lLLVMMCParser -lLLVMMC -lLLVMSupport -lrt -ldl -lpthread -lz -lm
For clang, we have to manually write the libs, but for llvm we simply use
llvm-config, you can check the scripts for clang's libs [1] and llvm [2].
~
But as a suggestion, I would not rely on getNameAsString, as it is
deprecated for quite a while. Try changing to *getName().str()* and it
should work for any C declaration (I'm not completely sure about that,
though). For C++ declarations (specially constructors and destructors), I
use the following method:
std::string clang_c_convertert::get_decl_name(
const clang::NamedDecl &decl)
{
if(const clang::IdentifierInfo *identifier = decl.getIdentifier())
return identifier->getName().str();
std::string name;
llvm::raw_string_ostream rso(name);
decl.printName(rso);
return rso.str();
}
It shoudl work for any C or C++ declaration.
Thank you,
[0] https://github.com/esbmc/esbmc
[1]
https://github.com/esbmc/esbmc/blob/master/scripts/build-aux/m4/ax_clang.m4
[2]
https://github.com/esbmc/esbmc/blob/master/scripts/build-aux/m4/ax_llvm.m4
2016-07-14 15:12 GMT+01:00 folkert via cfe-users <cfe-users at lists.llvm.org>:
> Hi,
>
> What is the order of the clang libraries when linking?
>
> Currently I'm doing:
>
> clang++ -fno-rtti `llvm-config --cxxflags` \
> iterate.cpp \
> `llvm-config --ldflags --libs --system-libs` \
> -I/usr/lib/llvm-3.8/include -ggdb3 -std=c++11
> -I/usr/include/llvm-3.8/llvm/Support -L/usr/lib/llvm-3.8/lib/
> -L/usr/lib/gcc/x86_64-linux-gnu/5/ -I/usr/include/c++/5/
> -I/usr/include/x86_64-linux-gnu/c++/5/ -I/usr/lib/llvm-3.8/include/ \
> -lclangTooling -lclangFrontend -lclangDriver -lclangSerialization
> -lclangParse -lclangSema -lclangAnalysis -lclangEdit -lclangAST -lclangLex
> -lclangBasic -lLLVM -ldl
>
> but this gives me:
>
> /tmp/iterate-66d196.o: In function `getNameAsString':
> /usr/lib/llvm-3.8/include/clang/AST/Decl.h:184: undefined reference to
> `clang::DeclarationName::getAsString() const'
>
> Thanks in advance.
>
>
> Folkert van Heusden
>
> --
> ----------------------------------------------------------------------
> Phone: +31-6-41278122, PGP-key: 1F28D8AE, www.vanheusden.com
> _______________________________________________
> cfe-users mailing list
> cfe-users at lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-users
>
--
Mikhail Ramalho.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-users/attachments/20160714/1f2d6123/attachment.html>
More information about the cfe-users
mailing list