如何在 debian 11 上安装 gcc 和 build-essential?

如何在 debian 11 上安装 gcc 和 build-essential?

在里面/etc/apt/sources.list,允许的来源是

deb http://deb.debian.org/debian buster main contrib non-free
deb http://deb.debian.org/debian-security/ buster/updates main contrib non-free
deb http://deb.debian.org/debian buster-updates main contrib non-free
deb http://emacs.ganneff.de/ buster main

我安装了这些软件包

$ sudo apt-get update; sudo apt-get install make build-essential libssl-dev zlib1g-dev \
libbz2-dev libreadline-dev libsqlite3-dev wget curl llvm \
libncursesw5-dev xz-utils tk-dev libxml2-dev libxmlsec1-dev libffi-dev liblzma-dev

其中一些无法安装。输出消息是

Hit:1 http://deb.debian.org/debian buster InRelease
Hit:2 http://deb.debian.org/debian-security buster/updates InRelease
Hit:3 http://deb.debian.org/debian buster-updates InRelease
Hit:4 http://emacs.ganneff.de buster InRelease
Reading package lists... Done
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
curl is already the newest version (7.64.0-4+deb10u2).
make is already the newest version (4.2.1-1.2).
make set to manually installed.
wget is already the newest version (1.21-1+deb11u1).
xz-utils is already the newest version (5.2.5-2.1~deb11u1).
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:
 dpkg-dev : Depends: libdpkg-perl (= 1.19.7) but 1.20.9 is to be installed
        Recommends: fakeroot
        Recommends: libalgorithm-merge-perl but it is not going to be installed
 g++ : Depends: cpp (= 4:8.3.0-1) but 4:10.2.1-1 is to be installed
 gcc : Depends: cpp (= 4:8.3.0-1) but 4:10.2.1-1 is to be installed
 libbz2-dev : Depends: libbz2-1.0 (= 1.0.6-9.2~deb10u1) but 1.0.8-4 is to be installed
          Recommends: bzip2-doc but it is not going to be installed
 libc6-dev : Depends: libc6 (= 2.28-10+deb10u1) but 2.31-13+deb11u2 is to be installed
         Depends: libc-dev-bin (= 2.28-10+deb10u1) but it is not going to be installed
 libfontconfig1-dev : Depends: libfontconfig1 (= 2.13.1-2) but 2.13.1-4.2 is to be installed
                  Depends: libexpat1-dev but it is not going to be installed
                  Depends: uuid-dev but it is not going to be installed
 libfreetype6-dev : Depends: libfreetype6 (= 2.9.1-3+deb10u2) but 2.10.4+dfsg-1 is to be installed
                Depends: libpng-dev but it is not going to be installed
 liblzma-dev : Depends: liblzma5 (= 5.2.4-1+deb10u1) but 5.2.5-2.1~deb11u1 is to be installed
 libncurses-dev : Depends: libtinfo6 (= 6.1+20181013-2+deb10u2) but 6.2+20201114-2 is to be installed
              Depends: libncurses6 (= 6.1+20181013-2+deb10u2) but 6.2+20201114-2 is to be installed
              Depends: libncursesw6 (= 6.1+20181013-2+deb10u2) but 6.2+20201114-2 is to be installed
 libncursesw5-dev : Depends: libtinfo6 (= 6.1+20181013-2+deb10u2) but 6.2+20201114-2 is to be installed
 libsqlite3-dev : Depends: libsqlite3-0 (= 3.27.2-3+deb10u1) but 3.34.1-3 is to be installed
 libssl-dev : Depends: libssl1.1 (= 1.1.1n-0+deb10u2) but 1.1.1n-0+deb11u2 is to be installed
 libx11-dev : Depends: libx11-6 (= 2:1.6.7-1+deb10u2) but 2:1.7.2-1 is to be installed
          Depends: libxau-dev (>= 1:1.0.0-1) but it is not going to be installed
          Depends: libxcb1-dev but it is not going to be installed
 libxext-dev : Depends: libxext6 (= 2:1.3.3-1+b2) but 2:1.3.3-1.1 is to be installed
 libxml2-dev : Depends: libxml2 (= 2.9.4+dfsg1-7+deb10u3) but 2.9.10+dfsg-6.7 is to be installed
 libxmlsec1-dev : Depends: libgcrypt20-dev but it is not going to be installed
              Depends: libgnutls28-dev but it is not going to be installed
              Depends: libnss3-dev but it is not going to be installed
              Depends: libxmlsec1 (= 1.2.27-2) but 1.2.31-1 is to be installed
              Depends: libxmlsec1-nss (= 1.2.27-2) but 1.2.31-1 is to be installed
              Depends: libxslt1-dev (>= 1.0.20) but it is not going to be installed
 libxt-dev : Depends: libxt6 (= 1:1.1.5-1+b3) but 1:1.2.0-1 is to be installed
         Depends: libsm-dev but it is not going to be installed
 zlib1g-dev : Depends: zlib1g (= 1:1.2.11.dfsg-1+deb10u1) but 1:1.2.11.dfsg-2+deb11u1 is to be installed
E: Unable to correct problems, you have held broken packages.

为什么这么多依赖项不匹配?如何安装它们?

答案1

问题是由于配置名称错误造成的。我编辑了/etc/apt/sources.list如下

deb http://deb.debian.org/debian bullseye main
deb-src http://deb.debian.org/debian bullseye main

deb http://deb.debian.org/debian-security/ bullseye-security main
deb-src http://deb.debian.org/debian-security/ bullseye-security main

deb http://deb.debian.org/debian bullseye-updates main
deb-src http://deb.debian.org/debian bullseye-updates main

它工作完美。

官方 SourcesList 文档在这里:

https://wiki.debian.org/SourcesList

相关内容