首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
社区首页 >问答首页 >Ubuntu 20.04 gcc报告错误版本

Ubuntu 20.04 gcc报告错误版本
EN

Ask Ubuntu用户
提问于 2022-03-09 03:03:45
回答 1查看 718关注 0票数 2

当试图在我的20.04 LTS主机上安装nvidia专有驱动程序时,我遇到了一个在使用DKMS时它不会安装的问题。它抱怨gcc的内核版本(9.3.0)和gcc版本(9.4.0)之间的错误。问题发生在升级到最新的内核版本之后。在运行gcc版本时,它报告了9.4.0,而apt显示gcc报告了9.3.0。

代码语言:javascript
代码运行次数:0
运行
复制
gcc --version
gcc (Ubuntu 9.4.0-1ubuntu1~20.04) 9.4.0

apt show gcc
Package: gcc
Version: 4:9.3.0-1ubuntu2

lsb_release -a
LSB Version:    core-11.1.0ubuntu2-noarch:security-11.1.0ubuntu2-noarch
Distributor ID: Ubuntu
Description:    Ubuntu 20.04.4 LTS
Release:    20.04
Codename:   focal

uname -a
Linux xenon 5.4.0-104-generic #118-Ubuntu SMP Wed Mar 2 19:02:41 UTC 2022 x86_64 x86_64 x86_64 GNU/Linux

在我看来,问题似乎是gcc的包是9.3.0,如apt所示,但报告9.4.0。

有什么建议吗?

正如在一篇评论中所说,我看不到老gcc的版本。我的sources.list文件可能是问题所在吗?看起来是这样的:

代码语言:javascript
代码运行次数:0
运行
复制
###### Ubuntu Main Repos
deb http://archive.ubuntu.com/ubuntu/ focal main restricted multiverse universe
deb-src http://archive.ubuntu.com/ubuntu/ focal main restricted multiverse universe
###### Ubuntu Update Repos
deb http://archive.ubuntu.com/ubuntu/ focal-security main restricted multiverse universe
deb http://archive.ubuntu.com/ubuntu/ focal-updates main restricted multiverse universe
deb-src http://archive.ubuntu.com/ubuntu/ focal-security main restricted multiverse universe
deb-src http://archive.ubuntu.com/ubuntu/ focal-updates main restricted multiverse universe
EN

回答 1

Ask Ubuntu用户

发布于 2022-03-11 23:16:45

我能够通过暂时将gcc降级到9.3来绕过这个问题,然后我可以编译nVidia驱动程序:

使用智能,我降级,然后持有g++-9,它会自动保存它的相关包。如果你喜欢的话,你也可以使用“apt-标记保持”。

下面是在我的系统中暂时保持状态的包:

代码语言:javascript
代码运行次数:0
运行
复制
[HOLD, DEPENDENCIES] cpp-9:amd64 9.3.0-10ubuntu2
[HOLD, DEPENDENCIES] g++-9:amd64 9.3.0-10ubuntu2
[HOLD, DEPENDENCIES] gcc-9:amd64 9.3.0-10ubuntu2
[HOLD, DEPENDENCIES] gcc-9-base:amd64 9.3.0-10ubuntu2
[HOLD, DEPENDENCIES] libasan5:amd64 9.3.0-10ubuntu2
[HOLD, DEPENDENCIES] libgcc-9-dev:amd64 9.3.0-10ubuntu2
[HOLD, DEPENDENCIES] libstdc++-9-dev:amd64 9.3.0-10ubuntu2

一旦用gcc 9.4编译了系统的新内核(即使用:

代码语言:javascript
代码运行次数:0
运行
复制
cat /proc/version

检查)或者当您不再需要重新编译nVidia驱动程序时,您应该能够释放已保存的9.4GCC升级,并将它们安装在您的系统上。

编辑:根据您的请求,这里有一个/etc/apt/ request。列表可以使用:

代码语言:javascript
代码运行次数:0
运行
复制
# See http://help.ubuntu.com/community/UpgradeNotes for how to upgrade to
# newer versions of the distribution.
deb http://archive.ubuntu.com/ubuntu/ focal main restricted
deb-src http://archive.ubuntu.com/ubuntu/ focal main restricted

## Major bug fix updates produced after the final release of the
## distribution.
deb http://archive.ubuntu.com/ubuntu/ focal-updates main restricted
deb-src http://archive.ubuntu.com/ubuntu/ focal-updates main restricted

## N.B. software from this repository is ENTIRELY UNSUPPORTED by the Ubuntu
## team. Also, please note that software in universe WILL NOT receive any
## review or updates from the Ubuntu security team.
deb http://archive.ubuntu.com/ubuntu/ focal universe
deb-src http://archive.ubuntu.com/ubuntu/ focal universe
deb http://archive.ubuntu.com/ubuntu/ focal-updates universe
deb-src http://archive.ubuntu.com/ubuntu/ focal-updates universe

## N.B. software from this repository is ENTIRELY UNSUPPORTED by the Ubuntu 
## team, and may not be under a free licence. Please satisfy yourself as to 
## your rights to use the software. Also, please note that software in 
## multiverse WILL NOT receive any review or updates from the Ubuntu
## security team.
deb http://archive.ubuntu.com/ubuntu/ focal multiverse
deb-src http://archive.ubuntu.com/ubuntu/ focal multiverse
deb http://archive.ubuntu.com/ubuntu/ focal-updates multiverse
deb-src http://archive.ubuntu.com/ubuntu/ focal-updates multiverse

## N.B. software from this repository may not have been tested as
## extensively as that contained in the main release, although it includes
## newer versions of some applications which may provide useful features.
## Also, please note that software in backports WILL NOT receive any review
## or updates from the Ubuntu security team.
deb http://archive.ubuntu.com/ubuntu/ focal-backports main restricted universe multiverse
deb-src http://archive.ubuntu.com/ubuntu/ focal-backports main restricted universe multiverse

deb http://security.ubuntu.com/ubuntu focal-security main restricted
deb-src http://security.ubuntu.com/ubuntu focal-security main restricted
deb http://security.ubuntu.com/ubuntu focal-security universe
deb-src http://security.ubuntu.com/ubuntu focal-security universe
deb http://security.ubuntu.com/ubuntu focal-security multiverse
deb-src http://security.ubuntu.com/ubuntu focal-security multiverse

请试一试。网站上有手册和教程。

票数 0
EN
页面原文内容由Ask Ubuntu提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://askubuntu.com/questions/1396629

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档