Ubuntu安裝gcc、g++、CMake
1. gcc
Ubuntu下自帶gcc編譯器。通過“gcc -v”命令來查看gcc版本。?
Ubuntu版本可通過“uname -a”命令查看剧包。
2. g++
安裝g++,可以通過命令“sudo apt-get install build-essential”實(shí)現(xiàn)往果。?
執(zhí)行完后疆液,就完成了gcc,g++,make的安裝。build-essential是一整套工具陕贮,gcc堕油,libc等。?
通過“g++ -v”可以查看g++版本。
“sudo apt-get install build-essential –fix-missing”命令是修補(bǔ)安裝build-essential掉缺,即已安裝了部分build-essential卜录,但沒有安裝完全,此時(shí)可以使用該命令繼續(xù)安裝build-essential眶明。
如果在安裝時(shí)出現(xiàn)了如下錯(cuò)誤:
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
然后即可蜀肘。
1绊汹、Ubuntu自帶的apt-get install方式安裝的CMake。
2扮宠、安裝其他版本西乖。?
首先卸載已經(jīng)安裝的CMake
apt-getautoremove cmake
1
然后下載cmake,以”cmake-3.5.0-Linux-x86_64.tar.gz”為例坛增。?
將其移動(dòng)到 /usr 目錄下并解壓
cd/usr
1
tar zxvf cmake-3.5.0-Linux-x86_64.tar.gz
1
解壓后的目錄結(jié)構(gòu):
tree?
├── bin?
│ ├── ccmake?
│ ├── cmake?
│ ├── cmake-gui?
│ ├── cpack?
│ └── ctest?
├── doc?
│ └── cmake-2.8?
├── man?
│ └── man1?
└── share?
├── aclocal?
├── applications?
├── cmake-2.8?
├── mime?
└── pixmaps
bin下面有各種cmake家族的產(chǎn)品程序获雕。
然后創(chuàng)建鏈接:
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