c++ - 在 C++ 中使用 CLang

标签 c++ clang llvm

我的程序中有一个与包含文件相关的编译错误,在我的程序中我包含了这些文件:

#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"

使用g++编译程序时得到的错误信息是:

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.

我不知道如何解决这个问题,而且我不确定我是否正确安装了 CLang 库,所以你能告诉我如何解决这个问题或者如何在 linux 上正确安装它吗( Ubuntu)。

最佳答案

您似乎安装了 Clang header ,但没有安装 LLVM header (Clang 所依赖的 header )。编译代码时,您需要像往常一样将带有 -I 的 LLVM header 路径传递给编译器。

我会从 the Download page 中获取预构建的 Clang+LLVM并针对它进行编译/链接。

关于c++ - 在 C++ 中使用 CLang,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20363082/

相关文章:

optimization - 使用 LLVM JIT 编译 lua 包装的 C 函数?

c++ - 在 MFC 中设置控件扩展样式的最佳位置在哪里

C++ 成员函数的无效使用,你是不是忘记了( )?

c++ - 什么是 -D 编译器标志 C++(clang、GNU、MSVC)

c - 已编译二进制文件中的预初始化函数指针?

c++11 - constexpr 的函数参数等效项是什么?

c++ - 将转换后的 .obj 文件更改为 OpenGL 图元

c++ - 我应该使用对象作为图 block 吗?

parsing - 我可以使用LLVM解析Fortran吗?

programming-languages - LLVM 是否提供任何实现 "green threads"/轻量级进程的工具?