AHS
AHS

Reputation: 784

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).

Upvotes: 2

Views: 3233

Answers (2)

Helin Wang
Helin Wang

Reputation: 4202

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

Upvotes: 2

Eli Bendersky
Eli Bendersky

Reputation: 273844

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.

Upvotes: 6

Related Questions