问题描述
使用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