在 Ubuntu 14.04(当前安装 4.8)上安装较旧的 gcc 版本(3.4.3)

use*_*975 9 gcc compiler

我已经安装了 gcc 4.8,但我还需要安装 gcc 3.4.3。我已按照以下步骤操作:

  1. 从 gcc.parentingamerica.com/releases 下载了 gcc 3.4.3。
  2. 提取焦油。
  3. 。/配置
  4. 制作

然后它抛出这个错误:http : //paste.ubuntu.com/24807240/

请任何人都可以提出什么问题,以及如何要求 gcc 在安装后使用旧版本?

操作系统:Ubuntu 14.04 LTS,64 位

ank*_*540 15

通过运行检查您当前的版本 gcc -v

接下来,您要安装以前的版本。

  1. 为了 gcc-3.4

由于此版本在旧版本的 Ubuntu 中可用,因此我们需要为该版本提供适当的存储库。从一些搜索中,我发现它们如下,必须添加到/etc/apt/sources.list

deb     http://snapshot.debian.org/archive/debian/20070730T000000Z/ lenny main
deb-src http://snapshot.debian.org/archive/debian/20070730T000000Z/ lenny main
deb     http://snapshot.debian.org/archive/debian-security/20070730T000000Z/ lenny/updates main
deb-src http://snapshot.debian.org/archive/debian-security/20070730T000000Z/ lenny/updates main
Run Code Online (Sandbox Code Playgroud)

完成后sudo apt-get update,新的存储库将可用。

接下来,安装所需的编译器。我平时安装gccg++相同版本的互操作性。推荐用于一般用途。

因此,

sudo apt-get install gcc-3.4 g++-3.4

2. 检查可用的编译器

在这个阶段,一个将有两组编译器(一个用于g++gcc)。这些可以通过dpkg --list | grep compiler

dpkg --list | grep compiler

dpkg --list | grep compile
ii  g++                                                   4:4.8.2-1ubuntu6                                    amd64        GNU C++ compiler
ii  g++-3.4                                               3.4.6-5                                             amd64        The GNU C++ compiler
ii  g++-4.8                                               4.8.4-2ubuntu1~14.04.1                              amd64        GNU C++ compiler
ii  gcc                                                   4:4.8.2-1ubuntu6                                    amd64        GNU C compiler
ii  gcc-3.4                                               3.4.6-5                                             amd64        The GNU C compiler
ii  gcc-4.8                                               4.8.4-2ubuntu1~14.04.1                              amd64        GNU C compiler
ii  hardening-includes                                    2.5ubuntu2.1                                        all          Makefile for enabling compiler flags for security hardening
ii  libllvm3.6:amd64                                      1:3.6-2ubuntu1~trusty1                              amd64        Modular compiler and toolchain technologies, runtime library
ii  libxkbcommon0:amd64                                   0.4.1-0ubuntu1                                      amd64        library interface to the XKB compiler - shared library
ii  pkg-config                                            0.26-1ubuntu4                                       amd64        manage compile and link flags for libraries
Run Code Online (Sandbox Code Playgroud)

如果需要,您可以检查安装位置。

重要的是两套编译器的位置,可以通过以下方式列出,

ls -lh /usr/bin/gcc*
lrwxrwxrwx 1 root root    7  5? 13  2016 /usr/bin/gcc -> gcc-4.8
-rwxr-xr-x 1 root root  91K  1?  4  2007 /usr/bin/gcc-3.4
-rwxr-xr-x 1 root root 758K  1? 27  2016 /usr/bin/gcc-4.8
Run Code Online (Sandbox Code Playgroud)

    ls -lh /usr/bin/g++*
lrwxrwxrwx 1 root root    7  4?  8  2014 /usr/bin/g++ -> g++-4.8
-rwxr-xr-x 1 root root  93K  1?  4  2007 /usr/bin/g++-3.4
-rwxr-xr-x 1 root root 758K  1? 27  2016 /usr/bin/g++-4.8
Run Code Online (Sandbox Code Playgroud)
  1. 为当前目的选择编译器(构建应用程序)

在安装了所需的编译器后,可以简单地在编译器之间切换。这是通过更新应用程序的替代版本列表来完成的。为此,update-alternative必须使用某些参数运行该命令。

sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-4.8 60 --slave /usr/bin/g++ g++ /usr/bin/g++-4.8
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-3.4 40 --slave /usr/bin/g++ g++ /usr/bin/g++-3.4
sudo update-alternatives --config gcc
Run Code Online (Sandbox Code Playgroud)

这将链接g++gcc和上只改变gccg++会自动改变。

然后每当你想改变编译器输入这个:

sudo update-alternatives --config gcc
Run Code Online (Sandbox Code Playgroud)

然后,询问用户选择哪个编译器。

    sudo update-alternatives --config gcc
    There are 2 choices for the alternative gcc (providing /usr/bin/gcc).

      Selection    Path              Priority   Status
    ------------------------------------------------------------
    * 0            /usr/bin/gcc-4.8   60        auto mode
      1            /usr/bin/gcc-3.4   40        manual mode
      2            /usr/bin/gcc-4.8   60        manual mode

Press enter to keep the current choice[*], or type selection number:
Run Code Online (Sandbox Code Playgroud)

在这里,您可以通过按 (0,1) 键然后按 Enter 来选择。可以通过以下方式检查当前所选版本的更改gcc -v


删除 update-alternative

  1. 如果您想保留安装的替代编译器。然后只需更改为自动模式,update-alternative即选项 0。
  2. 如果你想删除替代编译器,那么删除编译器就像sudo apt-get remove gcc-3.4 g++-3.4 然后运行

sudo update-alternatives --config gcc

该程序update-alternatives将查找链接并发现它们丢失,并会自动删除替代选项,返回到其他可用选项。

sudo update-alternatives --config gcc
update-alternatives: warning: alternative /usr/bin/gcc-3.4 (part of link group gcc) doesn't exist; removing from list of alternatives
There is only one alternative in link group gcc (providing /usr/bin/gcc): /usr/bin/gcc-4.8
Nothing to configure.
Run Code Online (Sandbox Code Playgroud)