简体   繁体   中英

Working with CLang in c++

I have a compilation error in my program related to the included files, in my program I am including this files:

#include "clang/AST/ASTConsumer.h"
#include "clang/AST/RecursiveASTVisitor.h"
#include "clang/Frontend/CompilerInstance.h"
#include "clang/Frontend/FrontendAction.h"
#include "clang/Tooling/Tooling.h"

The error message I get when I compile the program using g++ is:

In file included from /usr/include/clang/AST/APValue.h:17:0,
                 from /usr/include/clang/AST/Decl.h:17,
                 from /usr/include/clang/AST/RecursiveASTVisitor.h:17,
                 from FindClassDecls.cpp:2:
/usr/include/clang/Basic/LLVM.h:20:34: fatal error: llvm/Support/Casting.h: No such file or directory
compilation terminated.

I don't have any idea how to solve the problem, and also I am not sure that I installed the CLang library correctly, so can you please tell me how to solve the problem or how to install it correctly on linux (Ubuntu).

It seems that you have the Clang headers installed, but not the LLVM headers (which Clang relies upon). When you are compiling your code, you need to pass the path of LLVM headers with -I to your compiler, as usual.

I'd grab a pre-built Clang+LLVM from the Download page and compile/link against that.

sudo apt-get install libclang-3.8-dev#或libclang-3.9-dev

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM