Debian

Debian 6 Squeeze - 安裝 build-essentials - gcc / g++

  • December 7, 2018

我需要安裝 c / c++ 編譯器,我聽說最好的辦法是為此目的安裝 gcc/g++(我想我的機器上沒有它)。

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

如果我安裝了 c/c++ 編譯器隨附的 build-essential,我也會閱讀。所以我所做的是:

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.(希望我能清楚地表達我的觀點)。提前致謝。

您似乎混合了 Debian stable (squeeze) 和 Debian testing (wheezy) 或不穩定 (sid)。具體來說,您的libc6包是測試/不穩定版本,但您的包源指向穩定。

你需要在穩定、測試和不穩定之間選擇一個分佈——你不能真正混合它們(如果你不介意偶爾的煩惱,你可以混合測試和不穩定,但穩定相距太遠)。

如果你選擇穩定,你需要降級你的系統。支持降級apt-get,但您可能會遇到一些麻煩,因為並非所有軟體包都支持降級。由於您是 Debian 新手,我建議您重新安裝,除非您已經對系統進行了很多定制。您可以保存和恢復您的主目錄;還備份/etc目錄,但僅根據具體情況從中恢復文件。

如果您選擇測試或不穩定,請編輯您的軟體源/etc/apt/sources.list使其具有testingwheezyunstablesid現在所說的stablesqueeze

順便說一句,安裝build-essential軟體包是安裝開發工具的好方法,這是對的。gcc 是 Linux 上事實上的標準 C 和 C++ 編譯器;如果您有非常特殊的要求,您只會使用另一個。

引用自:https://unix.stackexchange.com/questions/24432