make install 时出错:“无法复制文件”

make install 时出错:“无法复制文件”

我正在尝试安装 CLHEP 2.3.4.4 但遇到问题,出现错误make install

[ 99%] Built target exctest3 
[ 99%] Built target exctestNothrow
[100%] Built target testzmex
Install the project...
-- Install configuration: "RelWithDebInfo"
-- Installing: /usr/local/bin/clhep-config
CMake Error at cmake_install.cmake:36 (file):
  file INSTALL cannot copy file
  "/home/ivan/CLHEP/2.3.4.4/CLHEP/2.3.4.4-build/clhep-config" to
  "/usr/local/bin/clhep-config".
Makefile:105: recipe for target 'install' failed
make: *** [install] Error 1

我该如何修复此问题?

答案1

尝试sudo make install

要访问/usr安装目录以存储系统范围的文件,安装程序需要 root 权限。因此,您不能仅以make install普通用户帐户的身份运行,而需要使用sudo提升权限。

答案2

如果不想使用 root/sudo 进行安装,请尝试DCMAKE_INSTALL_PREFIX以下选项:

mkdir -p $HOME/opt
cmake -DCMAKE_INSTALL_PREFIX=$HOME/opt .
make
make install

考虑将文件夹添加到 PATH,以便仅通过名称使用它

export PATH="$HOME/opt/bin:$PATH" # for binaries
export LD_LIBRARY_PATH="$HOME/opt/lib:$LD_LIBRARY_PATH" # for libs
export CPATH="$HOME/opt/include:$CPATH" # for includes

相关内容