CentOS7 安装 CMake 解决 cmake command not found 问题

时间:2025-04-06 16:53:06

下载

https://github.com/Kitware/CMake/releases

[root@ALiYunOgenes ~]# wget /Kitware/CMake/releases/download/v3.22.0/cmake-3.22.
  • 1

解压

[root@ALiYunOgenes ~]# tar zxf cmake-3.22. 

  • 1
  • 2

安装

[root@ALiYunOgenes ~]# cd cmake-3.22.0/
[root@ALiYunOgenes cmake-3.22.0]# ./bootstrap --prefix=/usr --datadir=share/cmake --docdir=doc/cmake && make
[root@ALiYunOgenes cmake-3.22.0]# make install
[root@ALiYunOgenes cmake-3.22.0]# cmake --version
  • 1
  • 2
  • 3
  • 4

note

内存不足时会报错 “ g++: internal compiler error: Killed (program cc1plus) ”,增加swap交换分区可解决。

g++: internal compiler error: Killed (program cc1plus)
Please submit a full bug report,
with preprocessed source if appropriate.
See </bugzilla> for instructions.
gmake: *** [] Error 4
---------------------------------------------
Error when bootstrapping CMake:
Problem while running gmake
---------------------------------------------
Log of errors: /root/cmake-3.22.0//cmake_bootstrap.log
---------------------------------------------
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11