安装g++时出现的一种报错及解决方案

在入门llvm的时候碰倒了各种错误,记录一下,也为其他人提供参考
环境:
主机WIN10+虚拟机vmware + ubuntu18.04 amd架构

ll@ubuntu:~/src/llvm-project-main/build$ cmake -DLLVM_ENABLE_PROJECTS=clang -G "Unix Makefiles" ../llvm
-- The CXX compiler identification is unknown
CMake Error at CMakeLists.txt:49 (project):
  No CMAKE_CXX_COMPILER could be found.

  Tell CMake where to find the compiler by setting either the environment
  variable "CXX" or the CMake cache entry CMAKE_CXX_COMPILER to the full path
  to the compiler, or to the compiler name if it is in the PATH.


-- Configuring incomplete, errors occurred!

我初次装cmake需要安装g++,那就安装把

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++-7 (>= 7.3.0-12~) but it is not going to be installed
E: Unable to correct problems, you have held broken packages.

安装失败,g++依赖g++ - 7,那再安装g++ - 7

sudo apt-get install g++-7
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++-7 : Depends: gcc-7-base (= 7.3.0-16ubuntu3) but 7.5.0-3ubuntu1~18.04 is to be installed
         Depends: gcc-7 (= 7.3.0-16ubuntu3) but 7.5.0-3ubuntu1~18.04 is to be installed
         Depends: libstdc++-7-dev (= 7.3.0-16ubuntu3) but it is not going to be installed
E: Unable to correct problems, you have held broken packages

·g++-7又依赖这些东西,这些东西安装不了,因为系统本身已经安装了这些包,导致版本不兼容,我的解决方案就是把他们全都卸载掉,重新让apt自己安装。

sudo apt-get remove gcc-7
sudo apt-get remove libstdc++-7-dev
sudo apt-get remove gcc-7-base

再次安装g++

sudo apt-get install g++

这时apt会自己找兼容的版本,,也可以先配置一个国内的源,要不安装的时候会有点慢。

  • 1
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值