将CMake与LLVM一起使用时出错 [英] Error when using CMake with LLVM

查看:436
本文介绍了将CMake与LLVM一起使用时出错的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以我试图使用LLVM构建一个玩具编译器,我想使用CMake作为构建系统.我尝试使用LLVM网站上的示例CMakeLists.txt ,但是在运行cmake时遇到以下错误:

So I'm trying to build a toy compiler using LLVM and I'd like to use CMake as my build system. I tried using the sample CMakeLists.txt from LLVM's website, but I encounter the following error when running 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/时,出现另一个错误:

When I went to go investigate the problem, I discovered that the path on my system is actually /usr/share/llvm-3.8/. When I tried changing the path to /usr/share/llvm/ like it expects, I get another error:

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打包系统的问题,还是我可以解决的问题?

I'm not really an expert on how exactly CMake works, so I'm not sure where to go from here. I'm running Ubuntu 16.04, and I've tried installing LLVM through various different packages with the same results. Is this a problem with Ubuntu's packaging system, or is something that I can fix?

推荐答案

AFAIK,这是Ubuntu包装中的一个众所周知的错误.原始问题仍然存在于Ubuntu 16.04上的llvm-3.8-dev中,请参见此处此处.

AFAIK, this is a well-known bug in Ubuntu's packaging. The original issue still persists in llvm-3.8-dev on Ubuntu 16.04 see here and here.

在尝试通过手动设置导入前缀来修复LLVMExports.cmake

When attempting to fix LLVMExports.cmake by manually setting the import prefix

set(_IMPORT_PREFIX "/usr/lib/llvm-3.8")

CMake能够找到libLLVMSupport.a和其他库.但是,我遇到了以下问题

CMake was able to find libLLVMSupport.a and other libraries. However, I was faced with the following issue

 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 config.

Surprisingly, library libPollyISL.a does not even exist in LLVM installation directory. Therefore, the problem is more than CMake config.

要节省时间,请从源代码自己构建LLVM并设置LLVM_DIR env变量.请参阅此教程.

To save time, build LLVM yourself from source and set LLVM_DIR env variable. See this tutorial.

这篇关于将CMake与LLVM一起使用时出错的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆