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-get install build-essential

Reading package lists... Done
Building dependency tree
Reading state information... Done
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-get update
sudo apt-get install build-essential.

然后即可。

3. CMake

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

2、安装其他版本。
首先卸载已经安装的CMake

apt-get autoremove cmake

然后下载cmake,以”cmake-3.5.0-Linux-x86_64.tar.gz”为例。
将其移动到 /usr 目录下并解压

cd /usr
tar zxvf cmake-3.5.0-Linux-x86_64.tar.gz

解压后的目录结构:

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/ 

查看CMake版本

cmake --version

cmake version 3.5.0
CMake suite maintained and supported by Kitware (kitware.com/cmake).
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值