cmake为root工作而不是为其他用户工作

时间:2013-05-14 16:42:03

标签: ubuntu cmake

我在buildbot slave中运行了一个虚拟编译。 当使用buildbot用户运行时,我得到:

-- The C compiler identification is unknown
-- The CXX compiler identification is unknown
-- Check for working C compiler: /usr/bin/gcc
-- Check for working C compiler: /usr/bin/gcc -- broken
CMake Error at /usr/share/cmake-2.8/Modules/CMakeTestCCompiler.cmake:52 (MESSAGE):
  The C compiler "/usr/bin/gcc" is not able to compile a simple test program.
...
cc1: error: /usr/local/include/x86_64-linux-gnu: Permission denied

/ usr / local / include / x86_64-linux-gnu不存在,但如果我手动运行它,我得到:

-- The C compiler identification is GNU
-- The CXX compiler identification is GNU
-- Check for working C compiler: /usr/bin/gcc
-- Check for working C compiler: /usr/bin/gcc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working CXX compiler: /usr/bin/c++
-- Check for working CXX compiler: /usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done

等等,我以后可以制作并运行生成的可执行文件 我假设与项目文件权限无关,因为所有文件都属于buildbot用户

命令运行只是cmake。 操作系统是ubuntu 12.04.1 LTS服务器版

由于

1 个答案:

答案 0 :(得分:2)

当CMake检查gcc是否有效时,它会创建一个临时文件并尝试编译它。根据我的经验,这总是在本地CMakeFiles文件目录中完成。看起来由于某种原因,它试图在/usr/local/include中执行此操作(至少在该文件夹中尝试某些,因此cc1: error: /usr/local/include/x86_64-linux-gnu: Permission denied)。

问题在于,当您指示 root有权访问该文件夹中的时。这对我来说有点奇怪,因为其他人至少应该被允许在那里阅读。无论如何,您的buildbot没有访问权限,因此配置失败。

您有三种选择。

  1. 深入了解CMake尝试访问此文件时正在执行的操作,并将其更改为在您拥有的位置执行操作。
  2. 更改/usr/local/include的权限,以便每个人都可以写信至/usr/local/include
  3. 创建buildbot所属的新组,并将/usr/local/include的组所有权更改为该组。确保将权限更改为770。
  4. 就个人而言,我会先尝试做第一个,因为我更喜欢CMake做本地的事情,而不是我系统的内容。您可以在CMakeFiles目录中找到一些日志文件。