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



我正试图运行一个将alfa代码转换为solidity智能合约的transiler项目,但在我运行最终命令make以生成将alfa转换为solidty的可执行文件后,我得到了以下错误:

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运行库相关的其他错误,也就是这个,但它没有答案:在linux上安装了antlr4 c++运行库后,一些include被破坏了。

感谢您的帮助。

这是错误的完整轨迹:

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

错误在于它想要设置/usr/local/include本身的权限,而不是向/usr/local/include添加内容。不管你赋予了什么权限,只有文件(或目录(的所有者才能更改该文件(或文件夹(的权限。

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

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

  1. 对于任何面临CMake项目问题的人来说,都可以在github问题中找到两个解决方案
    • FetchContent_MakeAvailable(googletest)之前添加option(INSTALL_GTEST OFF)
    • 如果改为使用add_subdirectory(googletest),则传递EXCLUDE_FROM_ALL以阻止安装
  2. 使用-D选项将INSTALL_GTEST=OFF传播到CMake。cmake -DINSTALL_GTEST=OFF

相关内容

  • 没有找到相关文章

最新更新