2018-09-15

Ubuntu安装gcc、g++、CMake

1. gcc

Ubuntu下自带gcc编译器。通过“gcc -v”命令来查看gcc版本。 

Ubuntu版本可通过“uname -a”命令查看。

2. g++

安装g++,可以通过命令“sudo apt-get install build-essential”实现。 

执行完后,就完成了gcc,g++,make的安装。build-essential是一整套工具,gcc,libc等。 

通过“g++ -v”可以查看g++版本。

“sudo apt-get install build-essential –fix-missing”命令是修补安装build-essential,即已安装了部分build-essential,但没有安装完全,此时可以使用该命令继续安装build-essential。

如果在安装时出现了如下错误:

sudo apt-getinstall build-essentialReading package lists...DoneBuilding dependency treeReading state information...DoneE: Unabletolocate package build-essential

1、sudo apt-get install build-essential

2

3、Reading package lists... Done

4、Building dependency tree

5、Reading state information... Done

6、E: Unable to locate package build-essential

build-essential is available on Main repository for 14.04. So first enable repository.

The main component contains applications that are free software, can be freely redistributed and are fully supported by the Ubuntu team. & The universe component is a snapshot of the free, open-source, and Linux world. 

You can enable Main & Universe repository by following command:

sudo add-apt-repository “deb http://archive.ubuntu.com/ubuntu $(lsb_release -sc) main universe”

Then install package by following command in terminal:

sudo apt-getupdatesudo apt-getinstall build-essential.

1

2

然后即可。

3. CMake

1、Ubuntu自带的apt-get install方式安装的CMake。

2、安装其他版本。 

首先卸载已经安装的CMake

apt-getautoremove cmake

1

然后下载cmake,以”cmake-3.5.0-Linux-x86_64.tar.gz”为例。 

将其移动到 /usr 目录下并解压

cd/usr

1

tar zxvf cmake-3.5.0-Linux-x86_64.tar.gz

1

解压后的目录结构:

tree 

├── bin 

│ ├── ccmake 

│ ├── cmake 

│ ├── cmake-gui 

│ ├── cpack 

│ └── ctest 

├── doc 

│ └── cmake-2.8 

├── man 

│ └── man1 

└── share 

├── aclocal 

├── applications 

├── cmake-2.8 

├── mime 

└── pixmaps

bin下面有各种cmake家族的产品程序。

然后创建链接:

ln-s/usr/cmake-3.5.0-Linux-x86_64/bin/* /usr/bin/

1

查看CMake版本

cmake--versioncmakeversion3.5.0CMake suite maintainedandsupportedbyKitware (kitware.com/cmake).


本文出处:https://blog.csdn.net/yvhqbat/article/details/50853196

你可能感兴趣的:(2018-09-15)