问题描述
使用cmake的make install命令时,出错:
# lib/CMakeLists.txt 中内容
install(TARGETS hello hello_static
LIBRARY DESTINATION lib
ARCHIVE DESTINATION lib)
install(FILES hello.h DESTINATION include/hello)
# bash中输入
cmake -DCMAKE_INSTALL_PREFIX=/usr ..
make
make install
在运行到make install时出错。
ayzp@ayzp-Lenovo-G40-45:~/backup/cmake/t3/build$ make install
[ 50%] Built target hello
[100%] Built target hello_static
Install the project...
-- Install configuration: ""
-- Up-to-date: /usr/lib/libhello.so.1.2
CMake Error at lib/cmake_install.cmake:48 (file):
file INSTALL cannot set permissions on "/usr/lib/libhello.so.1.2"
Call Stack (most recent call first):
cmake_install.cmake:37 (include)
解决
有些安装需要root密码,因而使用指令:
sudo make install
本文描述了在使用CMake进行项目构建时,遇到makeinstall命令无法设置目标文件权限的问题,并提供了通过sudo命令获取root权限来解决问题的方法。
495

被折叠的 条评论
为什么被折叠?



