Debian 6 Squeeze - 安装构建必需品 - gcc / g++

Debian 6 Squeeze - 安装构建必需品 - gcc / g++

我需要安装 c / c++ 编译器,我听说最好的办法是为此目的安装 gcc/g++ (我想我的机器上没有它)。

maistora@maistora:~$ gcc --version
bash: gcc: command not found

我还读到,如果我安装了 build-essential,则 c/c++ 编译器会附带它。所以我所做的是:

maistora@maistora:~$ sudo apt-get install build-essential
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:
 build-essential : Depends: libc6-dev but it is not going to be installed or
                            libc-dev
                   Depends: gcc (>= 4:4.4.3) but it is not going to be installed
                   Depends: g++ (>= 4:4.4.3) but it is not going to be installed
E: Broken packages

然后,我不知道为什么,但我决定一一安装依赖项并从以下开始,libc6-dev这是输出:

maistora@maistora:~$ sudo apt-get 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.11.2-10) but 2.13-21 is to be installed
             Depends: libc-dev-bin (= 2.11.2-10) but it is not going to be installed
             Recommends: gcc but it is not going to be installed or
                         c-compiler
E: Broken packages

我接下来做的事情是:

maistora@maistora:~$ sudo apt-get install libc6
Reading package lists... Done
Building dependency tree       
Reading state information... Done
libc6 is already the newest version.
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.

这对我来说似乎很奇怪。但我确信这对你来说是一些基本的东西。所以,我的问题是 - 如何在 Debian 6 Squeeze 上安装 build-essentials 或安装 gcc/g++ 的任何解决方法。

PS如果我写的话,sudo apt-get install gcc我会到达我的帖子的开头并以libc6 is already the newest version.(希望我清楚地表达我的观点)结尾。提前致谢。

答案1

您似乎混合了 Debian 稳定版 (squeeze) 和 Debian 测试版 (wheezy) 或不稳定版 (sid)。具体来说,您的库6软件包是测试/不稳定版本,但您的软件包源指向稳定版本。

你需要在稳定、测试和不稳定之间选择一个分布——你不能真正混合它们(如果你不介意偶尔的烦恼,你可以混合测试和不稳定,但稳定相差太远)。

如果您选择稳定,则需要降级您的系统。支持降级apt-get,但您可能会遇到一些麻烦,因为并非所有软件包都支持降级。由于您是 Debian 新手,我建议您重新安装,除非您已经对系统进行了很多自定义。您可以保存和恢复您的主目录;还可以备份该/etc目录,但只能根据具体情况从中恢复文件。

如果您选择测试或不稳定,请编辑您的软件来源在现在说or的地方/etc/apt/sources.listtestingorwheezyunstableor 。sidstablesqueeze

顺便说一句,安装build-essential软件包是安装开发工具的好方法,这是对的。而gcc是Linux上事实上的标准C和C++编译器;如果您有非常特殊的要求,您只会使用另一个。

答案2

刚打开/etc/apt/sources.list

并添加这些行:

deb http://packages.dotdeb.org squeeze all
deb-src http://packages.dotdeb.org squeeze all

保存,然后执行

apt-get update
apt-get upgrade

然后您将看到软件包将被安装。

相关内容