CMake 错误:文件安装无法在“/usr/local/include”上设置权限:不允许操作

问题描述 投票:0回答:3

我正在尝试运行一个将 alfa 代码转换为 Solidity 智能合约的转译器项目,但是在我运行最终命令

make
以生成将 alfa 转换为 Solidity 的可执行文件后,我得到了以下错误:

CMake Error at _deps/googletest-build/googlemock/cmake_install.cmake:46 (file):
  file INSTALL cannot set permissions on "/usr/local/include": Operation not
  permitted.
Call Stack (most recent call first):
  _deps/googletest-build/cmake_install.cmake:47 (include)
  runtime/cmake_install.cmake:47 (include)
  cmake_install.cmake:47 (include)

虽然我已经将 /usr/local/include 的权限设置为 777,但运行命令后仍然出现错误。

我尝试运行

sudo make
而不是
make
但后来我得到了与 antlr4-runtime 库相关的其他错误,就是这个,但它没有答案:一些包含在 antlr4 c++ 运行时设置后被破坏在 Linux 上

如有任何帮助,我们将不胜感激,谢谢。

这是错误的完整跟踪:

Consolidate compiler generated dependencies of target antlr4_tests
make[5]: Leaving directory '/home/ubuntu/new/transpiler/build6/antlr4cpp-prefix/src/antlr4cpp-build'
make  -f runtime/CMakeFiles/antlr4_tests.dir/build.make runtime/CMakeFiles/antlr4_tests.dir/build
make[5]: Entering directory '/home/ubuntu/new/transpiler/build6/antlr4cpp-prefix/src/antlr4cpp-build'
make[5]: Nothing to be done for '_deps/googletest-build/googlemock/CMakeFiles/gmock_main.dir/build'.
make[5]: Leaving directory '/home/ubuntu/new/transpiler/build6/antlr4cpp-prefix/src/antlr4cpp-build'
make[5]: Entering directory '/home/ubuntu/new/transpiler/build6/antlr4cpp-prefix/src/antlr4cpp-build'
make[5]: Nothing to be done for 'runtime/CMakeFiles/antlr4_tests.dir/build'.
make[5]: Leaving directory '/home/ubuntu/new/transpiler/build6/antlr4cpp-prefix/src/antlr4cpp-build'
[ 99%] Built target gmock_main
[100%] Built target antlr4_tests
make[4]: Leaving directory '/home/ubuntu/new/transpiler/build6/antlr4cpp-prefix/src/antlr4cpp-build'
/usr/bin/cmake -E cmake_progress_start /home/ubuntu/new/transpiler/build6/antlr4cpp-prefix/src/antlr4cpp-build/CMakeFiles 0
make  -f CMakeFiles/Makefile2 preinstall
make[4]: Entering directory '/home/ubuntu/new/transpiler/build6/antlr4cpp-prefix/src/antlr4cpp-build'
make[4]: Nothing to be done for 'preinstall'.
make[4]: Leaving directory '/home/ubuntu/new/transpiler/build6/antlr4cpp-prefix/src/antlr4cpp-build'
Install the project...
/usr/bin/cmake -P cmake_install.cmake
-- Install configuration: "Release"
-- Up-to-date: /usr/local/include
CMake Error at _deps/googletest-build/googlemock/cmake_install.cmake:46 (file):
  file INSTALL cannot set permissions on "/usr/local/include": Operation not
  permitted.
Call Stack (most recent call first):
  _deps/googletest-build/cmake_install.cmake:47 (include)
  runtime/cmake_install.cmake:47 (include)
  cmake_install.cmake:47 (include)


make[3]: *** [Makefile:130: install] Error 1
make[3]: Leaving directory '/home/ubuntu/new/transpiler/build6/antlr4cpp-prefix/src/antlr4cpp-build'
make[2]: *** [CMakeFiles/antlr4cpp.dir/build.make:102: antlr4cpp-prefix/src/antlr4cpp-stamp/antlr4cpp-install] Error 2
make[2]: Leaving directory '/home/ubuntu/new/transpiler/build6'
make[1]: *** [CMakeFiles/Makefile2:86: CMakeFiles/antlr4cpp.dir/all] Error 2
make[1]: Leaving directory '/home/ubuntu/new/transpiler/build6'
make: *** [Makefile:91: all] Error 2
c++ ubuntu cmake makefile antlr4
3个回答
1
投票

错误是它想设置

/usr/local/include
本身的权限,而不是给
/usr/local/include
添加内容。 无论您授予什么权限,只有文件(或目录)的所有者才能更改该文件(或目录)的权限。


0
投票

当我尝试安装使用 GoogleTest 库的 CMake 项目时,我遇到了类似的问题。该库会检查是否安装其二进制文件。请参阅此处

看起来,当 GNU 安装 antlr4-runtime 时,它会触发 GoogleTest 的安装,但这在您的情况下不是必需的。您有以下选择:

  1. 对于任何在 CMake 项目中遇到此问题的人,都可以在此 github 问题中找到两种解决方法
    • option(INSTALL_GTEST OFF)
       之前添加 
      FetchContent_MakeAvailable(googletest)
    • 如果使用
      add_subdirectory(googletest)
      ,请传递
      EXCLUDE_FROM_ALL
      以防止安装。
  2. 使用
    INSTALL_GTEST=OFF
    选项将
    -D
    传播到 CMake。
    cmake -DINSTALL_GTEST=OFF

0
投票

这似乎是一个cmake功能,当安装一个目录时,cmake会尝试对其设置权限,即使该目录在运行cmake之前已存在。 为什么不跳过对现有目录的权限设置?

© www.soinside.com 2019 - 2024. All rights reserved.