我正在尝试安装 这个 git repo 的代码。
我按照自述文件中的说明进行操作,但在执行
make
命令期间,我总是收到此错误:
pet.cc:73:10: fatal error: clang/Frontend/LangStandard.h: No such file or directory
73 | #include <clang/Frontend/LangStandard.h>
所以我想我需要单独安装 Clang,所以我按照这里的说明进行操作。
LLVM 和 Clang 安装似乎可以工作,但在调用
make
时仍然遇到相同的错误。
那么如何获取 clang 前端标头?
发生的另一件奇怪的事情:当按照存储库中的描述调用
./autogen.sh
时,我收到很多这样的警告
aclocal: warning: autoconf input should be named 'configure.ac', not 'configure.in'
或者这个
Makefile.am:10: warning: source file 'source/arith/errors.c' is in a subdirectory,
Makefile.am:10: but option 'subdir-objects' is disabled
automake: warning: possible forward-incompatibility.
automake: At least a source file is in a subdirectory, but the 'subdir-objects'
automake: automake option hasn't been enabled. For now, the corresponding output
automake: object file(s) will be placed in the top-level directory. However,
automake: this behaviour will change in future Automake versions: they will
automake: unconditionally cause object files to be placed in the same subdirectory
automake: of the corresponding sources.
automake: You are advised to start using 'subdir-objects' option throughout your
automake: project, to avoid future incompatibilities.
这是否也表明有问题?
问题是您正在尝试针对 Clang 版本进行编译 太新了。 Clang 的最后一个版本有
clang/Frontend/LangStandard.h
是版本 9:
https://github.com/llvm/llvm-project/blob/llvmorg-9.0.0/clang/include/clang/Frontend/LangStandard.h
版本 10 及更高版本缺少该文件:
https://github.com/llvm/llvm-project/tree/llvmorg-10.0.0/clang/include/clang/Frontend
在 github UI 中,您可以使用以下命令更改用于查看源代码的标签 左上角“文件”标题下的下拉菜单。我用过那个 (和二分搜索)以确定哪个版本删除了该文件。
但是,降级到 Clang 9 可能还不够老。回购协议 你正在尝试编译,https://github.com/spcl/haystack,是最后一个 更新于 2019 年 7 月,就在 Clang 8 发布之前,所以我的猜测是 它本来是用 Clang 7 编译的,而这恰好是最旧的版本 于 Clang+LLVM 发布页面.
一般来说,Clang API 从主要版本到 主要版本,同时仅保留次要版本的兼容性 版本到次要版本。所以你需要使用主要版本 最接近的可能匹配。不幸的是,除了审判之外没有简单的方法 如果客户端程序的作者确定正确的版本,则会出现错误 不指定他们使用哪个版本。 (快速浏览后,我看不到他们指定的任何地方。)