Install CMake on Ubuntu 12.04

来源:互联网 发布:阿里云账号可以注销吗 编辑:程序博客网 时间:2024/05/22 15:54

新电脑刚装好Ubuntu和无线网卡驱动,可以正常上网了。Ubuntu安装完后自带make,比如装无线网卡时候进入目录,make编译安装网卡驱动。也自带gcc,但不带g++编译器。而软件开发仅有gcc是不够的。现在开始配置项目环境。首先是CMake编译器。因为我故意没装Synaptic Package Manager,下文是用命令行安装。


Source code: cmake-3.1.0.tar.gz, can be download from: http://www.cmake.org/download/


1) 解压,配置。(其实安装包里的README.rst里的说明已经很详细。)

arac@test:~/Downloads$ cd cmake-3.1.0

arac@test:~/Downloads/cmake-3.1.0$ sudo ./bootstrap

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

CMake 3.1.0, Copyright 2000-2014 Kitware, Inc.

C compiler on this system is: cc

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

Error when bootstrapping CMake:

Cannot find appropriate C++ compiler on this system.

Please specify one using environment variable CXX.

See cmake_bootstrap.log for compilers attempted.

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

Log of errors: /home/ltu/Downloads/cmake-3.1.0/Bootstrap.cmk/cmake_bootstrap.log

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


问题很显然,缺少C++ compiler (g++)。可以简单的安装g++编译器,命令:


arac@test:~/Downloads/cmake-3.1.0$sudo apt-get install g++


也可以安装build-essential包,它包含g++。详见:“Install g++ compiler


装完g++,再次尝试:

arac@test:~/Downloads/cmake-3.1.0$sudo ./bootstrap

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

CMake 3.1.0, Copyright 2000-2014 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: make

g++ is GNU compiler

g++ has setenv

g++ has unsetenv

g++ does not have environ in stdlib.h

g++ has STL in std:: namespace

g++ has ANSI streams

g++ has streams in std:: namespace

g++ has sstream

g++ has operator!=(string, char*)

g++ has stl iterator_traits

g++ has standard template allocator

g++ has allocator<>::rebind<>

g++ does not have non-standard allocator<>::max_size argument

g++ has stl containers supporting allocator objects

g++ has stl wstring

g++ has header cstddef

g++ requires template friends to use <>

g++ supports member templates

g++ has standard template specialization syntax

g++ has argument dependent lookup

g++ has struct stat with st_mtim member

g++ has ios::binary openmode

g++ has ANSI for scoping

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

g++  -I/home/ltu/Downloads/cmake-3.1.0/Bootstrap.cmk -I/home/ltu/Downloads/cmake-3.1.0/Source   -I/home/ltu/Downloads/cmake-3.1.0/Bootstrap.cmk -c /home/ltu/Downloads/cmake-3.1.0/Source/cmStandardIncludes.cxx -o cmStandardIncludes.o

g++  -I/home/ltu/Downloads/cmake-3.1.0/Bootstrap.cmk -I/home/ltu/Downloads/cmake-3.1.0/Source   -I/home/ltu/Downloads/cmake-3.1.0/Bootstrap.cmk -c /home/ltu/Downloads/cmake-3.1.0/Source/cmake.cxx -o cmake.o

....

Curses libraries were not found. Curses GUI for CMake will not be built.

-- Configuring done

-- Generating done

-- Build files have been written to: /home/ltu/Downloads/cmake-3.1.0

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

CMake has bootstrapped.  Now run make.


前面忘记修改安装路径了,这里补充一下:

arac@test:~/Downloads/cmake-3.1.0$sudo ./configure --prefix=/usr/local/cmake-3.1.0


2) 编译

arac@test:~/Downloads/cmake-3.1.0$sudo make


3) 安装

arac@test:~/Downloads/cmake-3.1.0$sudo make install


瞬间就安装完成。可以看到已成功安装到/usr/local/cmake-3.1.0目录下。


4) 设置系统路径。

修改/etc/profile文件:

arac@test:/usr/local/cmake-3.1.0/bin$sudo gedit /etc/profile

在里面加入一行:

export PATH="$PATH:/usr/local/cmake-3.1.0/bin"

arac@test:/usr/local/cmake-3.1.0/bin$source /etc/profile


查看一下,PATH里已经有了:

arac@test:/usr/local/cmake-3.1.0/bin$echo $PATH

/usr/lib/lightdm/lightdm:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/cmake-3.1.0/bin


刚刚安装的cmake已被永久添加到系统PATH。

0 0
原创粉丝点击