所以我正在尝试使用 LLVM 构建一个玩具编译器,并且我想使用 CMake 作为我的构建系统。我尝试使用 sample CMakeLists.txt来自 LLVM 的网站,但在运行 cmake
时遇到以下错误:
CMake Error at /usr/share/llvm-3.8/cmake/LLVMConfig.cmake:178 (include):
include could not find load file:
/usr/share/llvm/cmake/LLVMExports.cmake
Call Stack (most recent call first):
CMakeLists.txt:4 (find_package)
CMake Error at /usr/share/llvm-3.8/cmake/LLVMConfig.cmake:181 (include):
include could not find load file:
/usr/share/llvm/cmake/LLVM-Config.cmake
Call Stack (most recent call first):
CMakeLists.txt:4 (find_package)
当我去排查问题时,我发现我系统上的路径实际上是/usr/share/llvm-3.8/
。当我尝试像预期的那样将路径更改为 /usr/share/llvm/
时,我收到另一个错误:
CMake Error at /usr/share/llvm/cmake/LLVMExports.cmake:1034 (message):
The imported target "LLVMSupport" references the file
"/usr/lib/libLLVMSupport.a"
but this file does not exist. Possible reasons include:
* The file was deleted, renamed, or moved to another location.
* An install or uninstall procedure did not complete successfully.
* The installation package was faulty and contained
"/usr/share/llvm/cmake/LLVMExports.cmake"
but not all the files it references.
我并不是 CMake 究竟是如何工作的专家,所以我不确定从这里该何去何从。我正在运行 Ubuntu 16.04,我尝试通过各种不同的包安装 LLVM,结果相同。这是 Ubuntu 打包系统的问题,还是我可以解决的问题?
最佳答案
据我所知,这是 Ubuntu 打包中的一个众所周知的错误。原始问题在 Ubuntu 16.04 上的 llvm-3.8-dev 中仍然存在,请参阅 here和 here .
尝试通过手动设置导入前缀修复 LLVMExports.cmake
时
set(_IMPORT_PREFIX "/usr/lib/llvm-3.8")
CMake 能够找到 libLLVMSupport.a
和其他库。但是,我遇到了以下问题
The imported target "PollyISL" references the file
"/usr/lib/llvm-3.8/lib/libPollyISL.a"
but this file does not exist. Possible reasons include:
令人惊讶的是,库 libPollyISL.a
甚至不存在于 LLVM 安装目录中。因此,问题不仅仅是CMake配置。
为了节省时间,从源代码自己构建 LLVM 并设置 LLVM_DIR 环境变量。看这个tutorial .
关于c++ - 将 CMake 与 LLVM 一起使用时出错,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38171543/