![make install 时出错:“无法复制文件”](https://linux22.com/image/1090489/make%20install%20%E6%97%B6%E5%87%BA%E9%94%99%EF%BC%9A%E2%80%9C%E6%97%A0%E6%B3%95%E5%A4%8D%E5%88%B6%E6%96%87%E4%BB%B6%E2%80%9D.png)
我正在尝试安装 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