c语言 - 为什么我不能安装 libc6-dev



我想编译一个 c 文件,但输入编译命令后发生错误。

~$ gcc helloworld.c -o helloworld
fatal error: stdio.h: No such file or directory
compilation terminated.

我根据互联网上的方法安装了libc6-dev

~$ sudo apt install libc6-dev

然后出现了这个错误

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:
libc6-dev : Depends: libc6 (= 2.23-0ubuntu11.3) but 2.31-0ubuntu9.2 is to be installed
Depends: libc-dev-bin (= 2.23-0ubuntu11.3)
E: Unable to correct problems, you have held broken packages.

所以我遵循了方法

sudo apt-get autoclean
Reading package lists... Done
Building dependency tree       
Reading state information... Done
sudo apt-get update
Hit:1 http://archive.canonical.com/ubuntu xenial InRelease
Hit:2 http://archive.ubuntu.com/ubuntu xenial InRelease
Hit:3 http://archive.ubuntu.com/ubuntu xenial-updates InRelease
Hit:4 http://archive.ubuntu.com/ubuntu xenial-backports InRelease
Hit:5 http://archive.ubuntu.com/ubuntu xenial-security InRelease
Reading package lists... Done
sudo apt-get upgrade
Reading package lists... Done
Building dependency tree       
Reading state information... Done
Calculating upgrade... Done
The following packages have been kept back:
ubuntu-advantage-tools
0 upgraded, 0 newly installed, 0 to remove and 1 not upgraded.
sudo apt-get -u dist-upgrade
Reading package lists... Done
Building dependency tree       
Reading state information... Done
Calculating upgrade... Done
The following packages have been kept back:
ubuntu-advantage-tools
0 upgraded, 0 newly installed, 0 to remove and 1 not upgraded.
sudo dpkg --configure -a
sudo apt-get -f install
Reading package lists... Done
Building dependency tree       
Reading state information... Done
0 upgraded, 0 newly installed, 0 to remove and 1 not upgraded.
sudo apt-get install libc6-i386
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:
libc6-i386 : Depends: libc6 (= 2.23-0ubuntu11.3) but 2.31-0ubuntu9.2 is to be installed
E: Unable to correct problems, you have held broken packages.

我该怎么办

我有 debian,但我认为这个解决方案可以帮助你。这是我添加到我的/etc/apt/sources.list 的新行

deb http://ftp.it.debian.org/debian bullseye-updates main contrib non-free   

您可以尝试安装特定版本的libc6

sudo apt update
sudo apt upgrade

sudo apt install libc6=2.35-0ubuntu3