sudo apt-get install g++
Reading package lists... Done
Building dependency tree
Reading state information... Done
Some packages could not be installed. This may mean that you have
requested an impossible situation or if you are using the unstable
distribution that some required packages have not yet been created
or been moved out of Incoming.
The following information may help to resolve the situation:
The following packages have unmet dependencies:
g++ : Depends: g++-4.7 (>= 4.7.0-1~) but it is not going to be installed
E: Unable to correct problems, you have held broken packages.
答案1
似乎您有一些损坏的软件包或依赖项。请尝试执行sudo apt-get update
,如果更新时出现错误,请尝试执行以下操作:
sudo apt-get clean
cd /var/lib/apt
sudo mv lists lists.backup
sudo mkdir -p lists/partial
sudo apt-get clean
sudo apt-get update
然后尝试安装 g++。
答案2
sudo apt-get update
然后始终运行sudo apt-get install g++
。该sudo apt-get clean
命令是可选的。我的安装没有它也能正常工作。
答案3
而不是仅仅安装g++
或者gcc
更建议安装build-essential
包。
您应该使用以下命令来安装它:
sudo apt-get 更新 sudo apt-get 安装 build-essential
这两个命令应该安装系统构建所需的所有基础知识。