源码安装cmake

第一步、安装gcc等必须的包

[root@localhost ~]# yum install -y gcc gcc-c++ make automake

Loaded plugins: fastestmirror, refresh-packagekit, security

Loading mirror speeds from cached hostfile

 * base: mirrors.skyshe.cn

 * extras: mirrors.yun-idc.com

 * updates: mirrors.skyshe.cn

Setting up Install Process

Package gcc-4.4.7-16.el6.x86_64 already installed and latest version

Package 1:make-3.81-20.el6.x86_64 already installed and latest version

Package automake-1.11.1-4.el6.noarch already installed and latest version

Resolving Dependencies

--> Running transaction check

---> Package gcc-c++.x86_64 0:4.4.7-16.el6 will be installed

--> Processing Dependency: libstdc++-devel = 4.4.7-16.el6 for package: gcc-c++-4.4.7-16.el6.x86_64

--> Processing Dependency: libstdc++ = 4.4.7-16.el6 for package: gcc-c++-4.4.7-16.el6.x86_64

--> Running transaction check

---> Package libstdc++.x86_64 0:4.4.7-4.el6 will be updated

---> Package libstdc++.x86_64 0:4.4.7-16.el6 will be an update

---> Package libstdc++-devel.x86_64 0:4.4.7-16.el6 will be installed

--> Finished Dependency Resolution


Dependencies Resolved


================================================================================

Package                 Arch           Version              Repository    Size

================================================================================

Installing:

gcc-c++                 x86_64         4.4.7-16.el6         base         4.7 M

Installing for dependencies:

libstdc++-devel         x86_64         4.4.7-16.el6         base         1.6 M

Updating for dependencies:

libstdc++               x86_64         4.4.7-16.el6         base         295 k


Transaction Summary

================================================================================

Install       2 Package(s)

Upgrade       1 Package(s)


Total download size: 6.6 M

Downloading Packages:

(1/3): gcc-c++-4.4.7-16.el6.x86_64.rpm                   | 4.7 MB     00:03     

(2/3): libstdc++-4.4.7-16.el6.x86_64.rpm                 | 295 kB     00:00     

(3/3): libstdc++-devel-4.4.7-16.el6.x86_64.rpm           | 1.6 MB     00:01     

--------------------------------------------------------------------------------

Total                                           1.2 MB/s | 6.6 MB     00:05     

Running rpm_check_debug

Running Transaction Test

Transaction Test Succeeded

Running Transaction

  Updating   : libstdc++-4.4.7-16.el6.x86_64                                1/4

  Installing : libstdc++-devel-4.4.7-16.el6.x86_64                          2/4

  Installing : gcc-c++-4.4.7-16.el6.x86_64                                  3/4

  Cleanup    : libstdc++-4.4.7-4.el6.x86_64                                 4/4

  Verifying  : libstdc++-4.4.7-16.el6.x86_64                                1/4

  Verifying  : libstdc++-devel-4.4.7-16.el6.x86_64                          2/4

  Verifying  : gcc-c++-4.4.7-16.el6.x86_64                                  3/4

  Verifying  : libstdc++-4.4.7-4.el6.x86_64                                 4/4


Installed:

  gcc-c++.x86_64 0:4.4.7-16.el6                                                 


Dependency Installed:

  libstdc++-devel.x86_64 0:4.4.7-16.el6                                         


Dependency Updated:

  libstdc++.x86_64 0:4.4.7-16.el6                                               


Complete!


第二步、安装wget

[root@localhost ~]# yum install -y wget

...此处具体过程省略...

Complete!


看到这个Complete!,说明wget也成功安装了。


第三步、获得cmake包

[root@localhost ~]# wget https://www.cmake.org/files/v2.8/cmake-2.8.10.2.tar.gz


...

100%[======================================>] 5,768,373   11.9K/s   in 6m 55s  


2015-09-21 17:02:18 (13.6 KB/s) - 鈥渃make-2.8.10.2.tar.gz鈥saved [5768373/5768373]


到这里,cmake包就down下来了。wget得到的包一般就在~下。如下,使用ls在~目录中看以看到cmake-2.8.10.2.tar.gz文件


[root@localhost ~]# ls

anaconda-ks.cfg        install.log         named.conf

cmake-2.8.10.2.tar.gz  install.log.syslog


第四步、使用tar命令解压

[root@localhost ~]# tar -zvxf cmake-2.8.10.2.tar.gz

解压过程忽略


第五步、进入cmake-2.8.10.2目录,执行./bootstrap

[root@localhost ~]# cd cmake-2.8.10.2

[root@localhost cmake-2.8.10.2]# ./bootstrap

---------------------------------------------

CMake 2.8.10.2, Copyright 2000-2012 Kitware, Inc.

Found GNU toolchain

C compiler on this system is: gcc

C++ compiler on this system is: g++ 

Makefile processor on this system is: gmake

g++ is GNU compiler

...忽略

---------------------------------------------

CMake has bootstrapped.  Now run gmake.


第六步、执行gmake

[root@localhost cmake-2.8.10.2]# gmake

Scanning dependencies of target cmIML_test

...

[100%] Built target pseudo_valgrind


第七步、执行gmake install

[root@localhost cmake-2.8.10.2]# gmake install

[  2%] Built target cmIML_test

...


运行完毕后,cmake安装完成,可阅读install_manifest.txt查看具体都安装了什么。


常见错误:

在第六步时可能会因为所需包安装不全报错,这时候只要把相关包安装后,将cmake-2.8.10.2/目录下的CMakeCache.txt删掉,再从步骤六开始即可。


评论

© 听雨残荷 | Powered by LOFTER