如何修复 CMake 安装?

如何修复 CMake 安装?

我在运行 Ubuntu 20 的远程计算机上安装了 CMake 3.16。

但是,我无法从命令行使用它:

user_name@192:~$ sudo apt install cmake
[sudo] password for user_name:
Reading package lists... Done
Building dependency tree
Reading state information... Done
cmake is already the newest version (3.16.3-1ubuntu1.20.04.1).
The following packages were automatically installed and are no longer required:
  linux-headers-5.15.0-75-generic linux-hwe-5.15-headers-5.15.0-75 linux-image-5.15.0-75-generic linux-modules-5.15.0-75-generic linux-modules-extra-5.15.0-75-generic
Use 'sudo apt autoremove' to remove them.
0 upgraded, 0 newly installed, 0 to remove and 4 not upgraded.
user_name@192:~$ cd CUDA_lab
user_name@192:~/CUDA_lab$ cd cuda_lab/
user_name@192:~/CUDA_lab/cuda_lab$ ls
CMakeLists.txt  googletest-master  include  main.cpp  src  test
user_name@192:~/CUDA_lab/cuda_lab$ cmake
CMake Error: Could not find CMAKE_ROOT !!!
CMake has most likely not been installed correctly.
Modules directory not found in
/usr/local/share/cmake-3.16
Usage

  cmake [options] <path-to-source>
  cmake [options] <path-to-existing-build>
  cmake [options] -S <path-to-source> -B <path-to-build>

Specify a source directory to (re-)generate a build system for it in the
current working directory.  Specify an existing build directory to
re-generate its build system.

Run 'cmake --help' for more information.

user_name@192:~/CUDA_lab/cuda_lab$

我该如何修复这个错误?

注意:几个月前它就起作用了。我不知道现在发生了什么。

答案1

cmake安装了两个相互冲突的版本。删除您手动安装的版本/usr/local并保留打包版本。看https://discourse.cmake.org/t/could-not-find-cmake-root/216/28

相关内容