ubuntun 安装gcc之后再安装对应的g++版本出错,显示E: Could not get lock /var/lib/dpkg/lock-frontend. It is held by proc

在安装gcc-5 之后接着继续安装对应的g++版本,然后出现如下错误

sudo apt-get install g++-5
E: Could not get lock /var/lib/dpkg/lock-frontend. It is held by process 12518 (unattended-upgr)
N: Be aware that removing the lock file is not a solution and may break your system.
E: Unable to acquire the dpkg frontend lock (/var/lib/dpkg/lock-frontend), is another process using it?

解决方法

如上面情况,注意第一行错误的 process 12518 ,正是这个apt进程还在运行,需要将它kill掉,执行如下命令:

sudo kill -9 12518

其中你只需要改的是 12518 这个进程id,看你报的错误是哪个,命令中的9是 SIGKILL 的信号数,它会杀掉第一个 apt 进程,不用管它。

之后就解决了

sudo apt-get install g++-5
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following packages were automatically installed and are no longer required:
  linux-headers-5.11.0-37-generic linux-hwe-5.11-headers-5.11.0-37
  linux-image-5.11.0-37-generic linux-modules-5.11.0-37-generic
  linux-modules-extra-5.11.0-37-generic
Use 'sudo apt autoremove' to remove them.
The following additional packages will be installed:
  libstdc++-5-dev
Suggested packages:
  g++-5-multilib gcc-5-doc libstdc++6-5-dbg libstdc++-5-doc
The following NEW packages will be installed:
  g++-5 libstdc++-5-dev
0 upgraded, 2 newly installed, 0 to remove and 173 not upgraded.
Need to get 9,857 kB of archives.
After this operation, 39.0 MB of additional disk space will be used.
Do you want to continue? [Y/n] y
Get:1 http://mirrors.aliyun.com/ubuntu xenial-updates/main amd64 libstdc++-5-dev amd64 5.4.0-6ubuntu1~16.04.12 [1,428 kB]
Get:2 http://mirrors.aliyun.com/ubuntu xenial-updates/main amd64 g++-5 amd64 5.4.0-6ubuntu1~16.04.12 [8,430 kB]
Fetched 9,857 kB in 2s (3,976 kB/s)
Selecting previously unselected package libstdc++-5-dev:amd64.
(Reading database ... 233784 files and directories currently installed.)
Preparing to unpack .../libstdc++-5-dev_5.4.0-6ubuntu1~16.04.12_amd64.deb ...
Unpacking libstdc++-5-dev:amd64 (5.4.0-6ubuntu1~16.04.12) ...
Selecting previously unselected package g++-5.
Preparing to unpack .../g++-5_5.4.0-6ubuntu1~16.04.12_amd64.deb ...
Unpacking g++-5 (5.4.0-6ubuntu1~16.04.12) ...
Setting up libstdc++-5-dev:amd64 (5.4.0-6ubuntu1~16.04.12) ...
Setting up g++-5 (5.4.0-6ubuntu1~16.04.12) ...
Processing triggers for man-db (2.9.1-1) ...

  • 3
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

匿名的魔术师

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值