gpt4 book ai didi

ubuntu - cmake 为 root 工作而不为其他用户工作

转载 作者:行者123 更新时间:2023-12-04 16:50:22 27 4
gpt4 key购买 nike

我有一个在 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 不存在,但如果我以 su 手动运行它,我会得到:

-- 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服务器版

谢谢

最佳答案

当 CMake 检查 gcc 是否工作时,它会创建一个临时文件并尝试编译它。根据我的经验,这总是在本地 CMakeFiles 文件目录中完成。看起来出于某种原因,它正试图在 /usr/local/include 中执行此操作(它至少正在尝试在该文件夹中执行某事,因此 cc1:错误:/usr/local/include/x86_64-linux-gnu:权限被拒绝)。

问题是,正如您所指出的,只有 root 有权读取写入该文件夹。这对我来说似乎有点奇怪,因为至少应该允许其他人在那里阅读。无论如何,您的 buildbot 在那里没有访问权限,因此配置失败。

您有三个选择。

  1. 深入了解 CMake 在尝试访问此文件时正在执行的操作,并将其更改为在您拥有的位置执行它正在执行的操作。
  2. 更改/usr/local/include的权限,让每个人都可以写入/usr/local/include
  3. 创建一个 buildbot 所属的新组,并将 /usr/local/include 的组所有权更改为该组。确保将权限更改为 770。

就个人而言,我会尝试第一个,因为我更喜欢 CMake 在本地做事,而不是在我的系统内部。您可以在 CMakeFiles 目录中找到一些日志文件。

关于ubuntu - cmake 为 root 工作而不为其他用户工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16548531/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com