下载cmake的源码,以cmake-3.3.1.tar.gz为例
tar zxvf cmake-3.3.1.tar.gz
cd cmake-3.3.1
./configure --prefix=/usr/local/cmake
然后发现缺少C++编译安装。
sudo apt-get install build-essential。
发现找不到源码
sudo apt-get update,
发现也没用。
找一些源 加到/etc/apt/sources.list,
sudo gedit /etc/apt/sources.list
把下面的内容粘贴到里面
debhttp://ftp.us.debian.org/debianstable main contrib non-free debhttp://ftp.us.debian.org/debian-non-USstable/non-US main contrib non-free debhttp://ftp.us.debian.org/debiantesting main contrib non-free debhttp://ftp.us.debian.org/debian-non-UStesting/non-US main contrib non-free debhttp://ftp.us.debian.org/debianunstable main contrib non-free debhttp://ftp.us.debian.org/debian-non-USunstable/non-US main contrib non-free
deb http://archive.ubuntu.com/ubuntu/ precise main restricted universe multiverse
deb http://archive.ubuntu.com/ubuntu/ precise-security main restricted universe multiverse
deb http://archive.ubuntu.com/ubuntu/ precise-updates main restricted universe multiverse
deb http://archive.ubuntu.com/ubuntu/ precise-proposed main restricted universe multiverse
deb http://archive.ubuntu.com/ubuntu/ precise-backports main restricted universe multiverse
deb-src http://archive.ubuntu.com/ubuntu/ precise main restricted universe multiverse
deb-src http://archive.ubuntu.com/ubuntu/ precise-security main restricted universe multiverse
deb-src http://archive.ubuntu.com/ubuntu/ precise-updates main restricted universe multiverse
deb-src http://archive.ubuntu.com/ubuntu/ precise-proposed main restricted universe multiverse
deb-src http://archive.ubuntu.com/ubuntu/ precise-backports main restricted universe multiverse
然后在sudo apt-get update
sudo apt-get upgrade
然后,执行
sudo apt-get install build-essential。
[错误2]
E: Could not get lock /var/lib/dpkg/lock - open (11: Resource temporarily unavailable) E: Unable to lock the administration directory (/var/lib/dpkg/), is another process using it?
出现这个问题可能是有另外一个程序正在运行,导致资源被锁不可用。而导致资源被锁的原因可能是上次运行安装或更新时没有正常完成,进而出现此状况,解决的办法其实很简单: 在终端中敲入以下两句 sudo rm /var/cache/apt/archives/lock sudo rm /var/lib/dpkg/lock
在终端输入:
sudo rm /var/cache/apt/archives/lock
sudo rm /var/libdpkg/lock
然后,重新输入
sudo apt-get install build-essential。
装完之后,重新
执行
./configure --prefix=/usr/local/cmake3.3.1
sudo make
sudo make install
安装完成之后。在终端输入 cmake --version.
发现没有找到。
修改环境变量
>su root
>gedit /etc/profile
export PATH=$PATH:/usr/local/cmake-3.3.1/bin
就可以在终端直接使用了。
cmake --version
----------------------------------------------------------------
参考文献:资源总结