首页 > 解决方案 > llvm-c/Types.h:没有这样的文件或目录

问题描述

我正在为 C 的一个子集编写一个玩具编译器。我正在为 AST 使用 flex、bison 和 LLVM。为了生成 AST,我编写了一个包含节点定义和继承细节的头文件。标题如下:

#include <iostream>
#include <vector>
#include <llvm-6.0/llvm/IR/Value.h>

....

使用以下命令序列编译我的文件后:

bison -d parser.y -o parser.cpp
flex -o tokens.cpp tokens.l
g++ -o parser parser.cpp tokens.cpp main.cpp

然后编译器抛出以下错误:

In file included from node.h:3:0,
                 from parser.y:2:
/usr/include/llvm-6.0/llvm/IR/Value.h:17:10: fatal error: llvm-c/Types.h: No such file or directory
 #include "llvm-c/Types.h"
          ^~~~~~~~~~~~~~~~
compilation terminated.
In file included from node.h:3:0,
                 from tokens.l:3:
/usr/include/llvm-6.0/llvm/IR/Value.h:17:10: fatal error: llvm-c/Types.h: No such file or directory
 #include "llvm-c/Types.h"
          ^~~~~~~~~~~~~~~~
compilation terminated.
In file included from node.h:3:0,
                 from main.cpp:2:
/usr/include/llvm-6.0/llvm/IR/Value.h:17:10: fatal error: llvm-c/Types.h: No such file or directory
 #include "llvm-c/Types.h"
          ^~~~~~~~~~~~~~~~
compilation terminated.

我尝试搜索“include”目录,“Types.h”文件在其他地方,而不是在“llvm/IR”目录中。在编译期间应该包括任何路径吗?任何帮助表示赞赏!

标签: compiler-constructionllvmabstract-syntax-treellvm-irllvm-c++-api

解决方案


推荐阅读