在c++中使用CLang
Working with CLang in c++
我的程序中有一个与包含的文件有关的编译错误,我的程序包括以下文件:
#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标头,但没有安装LLVM标头(Clang依赖于LLVM标头)。编译代码时,需要像往常一样,将带有-I
的LLVM头的路径传递给编译器。
我会从下载页面获取一个预构建的Clang+LLVM,并根据它进行编译/链接。
sudo apt-get-install libclang-3.8-dev#或libclang-39-dev
相关文章:
- 奇怪的结构&GCC&clang(void*返回类型)
- 数据成员SFINAE的C++17测试:gcc vs clang
- 当我编译webrtc服务器时,Windows上只支持clang-cl
- 为什么在Windows上的VS 2019和Clang 9中"size_t"在没有标题的情况下工作
- 我可以将一个用clang c++11编译的对象与另一个用c++17编译的对象链接起来吗
- Clang bug?使用指针作为模板参数
- clang整洁10忽略了我的NOLINT命令
- 如何防止clang格式在流运算符调用之间添加换行符<<
- 在clang++预处理器中确定gcc工具链版本
- 为什么 Clang 不允许"and"作为函数名称?
- 带有 -stdlib=libc++ 的 clang++ 9.0.1 找不到<optional>
- clang格式:宏的缩进
- CLANG 编译器 说:变量"PTR"可能未初始化
- clang格式:禁用排序包含
- 为什么lambda在clang上崩溃而不是在gcc上崩溃
- gcc和clang在表达式是否为常量求值的问题上存在分歧
- 循环展开 - G++ 与 Clang++
- 如何使用Clang/GCC在Mac上为C/C++设置VSCode
- 一位朋友将模板函数缩写为clang和gcc
- 类模板参数推导-clang和gcc不同