ubuntu - 如何指定 CMake 在 Ubuntu 中的安装位置?
问题描述
我已经下载了cmake-3.11.3-Linux-x86_64.sh
文件。然后我执行了它,它创建了一个文件夹,bin
里面有一个文件cmake
。我试图这样编辑/etc/environment
:
PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/home/m/FILES/CMake/cmake-3.11.3-Linux-x86_64/bin"
但是当我尝试这个命令时:
cmake -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=/usr/local ..
我收到这条消息:
当前未安装程序“cmake”。您可以通过键入安装它: sudo apt install cmake
我所做的哪一部分是错误的,我该如何解决?
解决方案
我假设您从CMake 的下载页面下载了脚本。诚然,如何使用它的文档有点稀疏。
简而言之,调用(此处 CMake 的安装路径为/usr/local
):
# sudo cmake-3.11.3-Linux-x86_64.sh --skip-license --exclude-subdir --prefix=/usr/local
注意:您需要先卸载任何包管理器安装的 CMake 包
# sudo apt remove cmake
# sudo apt purge --auto-remove cmake
选项
该脚本具有以下选项:
# cmake-3.11.3-Linux-x86_64.sh --help
Usage: cmake-3.11.3-Linux-x86_64.sh [options]
Options: [defaults in brackets after descriptions]
--help print this message
--version print cmake installer version
--prefix=dir directory in which to install
--include-subdir include the cmake-3.11.3-Linux-x86_64 subdirectory
--exclude-subdir exclude the cmake-3.11.3-Linux-x86_64 subdirectory
--skip-license accept license
您正在搜索的是--prefix=dir
. 否则它将只使用当前目录来提取安装文件。
在 Ubuntu 上测试输出
# cmake-3.11.3-Linux-x86_64.sh --skip-license --exclude-subdir --prefix=/usr/local
CMake Installer Version: 3.11.3, Copyright (c) Kitware
This is a self-extracting archive.
The archive will be extracted to: /usr/local
Using target directory: /usr/local
Extracting, please wait...
Unpacking finished successfully
# cmake --version
cmake version 3.11.3
CMake suite maintained and supported by Kitware (kitware.com/cmake).
参考/替代
推荐阅读
- docker - Kubernetes 服务不会在 Pod 之间分发请求
- amazon-web-services - Cloudwatch 访问超过 5 次的用户数
- java - 显示重复项目的回收站视图
- sql - 使用 PostgreSQL 从数组中获取标签
- r - 下采样 R 时训练/测试样本不是随机的
- python - 为什么我的代码在 .py 文件中运行时可以工作,但在 Python 解释器中返回 SyntaxError?
- cql - cqlsh:错误:没有这样的选项:--request-timeout
- python - SyntaxError (Python Jupyter Notebook)
- regex - 在 VS Code 中查找缺少两个右括号中的一个的字段
- javascript - 从 JSON 数组中删除元素