如何在 Ubuntu 16.04 上安装 gcc-5.3

use*_*262 8 apt ppa gcc 16.04

我目前正在运行Ubuntu 16.04并希望安装gcc-5.3从源代码,不中断gcc-5.4gcc-4.9在使用新立得软件包管理器我已经安装了。

我想要的原因gcc-5.3是我正在使用CUDA 8.0 RC,它不支持5.3. 4.9我不想降级到,而是想安装(或至少知道如何安装)5.3。我已经有了代码gcc-5.3,只需要通过configure/make/make install仪式。

现在,我需要在运行 make 和 make install 之前了解各种配置选项。我特别想确定我安装gcc-5.3在正确的位置并且不会干扰我现有的gcc-5.4gcc-4.9.

我找到了一个关于如何配置的帐户,5.3如下所示:

 ./gcc-5.3.0/configure --disable-checking --program-suffix=-5.3 --enable-languages=c,c++,go,objc --disable-multilib --with-system-zlib prefix=/usr/local/gcc-5.3
Run Code Online (Sandbox Code Playgroud)

这些选项中的一些是有意义的,其他的则没有。具体来说,我认为我非常理解不会弄乱自己的选项是:

--disable-checking: Will make the installation quicker, but at the risk 
                    of missing errors. Since I'm paranoid, I'll probably 
                    omit this option.

--disable-multilib: I don't understand this. I gather it has something 
                    to do with variations on the compiler's target machine,
                    but that's all I can gather. 
                    At worst, if I omit this option, I think I'll just
                    end up with some extra libraries, which doesn't seem 
                    so bad. Why do/don't I want to use this?

--with-system-zlib: Use the zlib that I already have with my system, 
                    rather than gcc's version. This seems reasonable to 
                    me.

--enable-languages=c,c++,go,objc: AFAIK, I'm really just interested in c & c++, 
                   so this option seems pretty harmless, although I might 
                   just use --enable-lnguages=all, since it can't hurt.
Run Code Online (Sandbox Code Playgroud)

确实让我担心的选项是:

--program-suffix=-5.3: This seems just to add a -5.3 suffix 
                       at the end of the installation path, 
                       which is probably a good idea if I get the 
                       path right

prefix=/usr/local/gcc-5.3: This just seems to specify the 
                           installation directory and to make the 
                           --program-suffix=-5.3 specification 
                           redundant. However, it is the option that 
                           makes me the most uneasy. 
Run Code Online (Sandbox Code Playgroud)

当我做 a 时find . -name gcc,我看到的唯一相关路径是/usr/lib/gcc/usr/bin/gcc

在 中/usr/lib/gcc,有两个子目录 -i686-linux-gnux86_64-linux-gnu,因为我有一台 64 位机器,所以我查看了 x64 目录。

在那里,我看到了一个软链接 - 4.9.3,它链接到一个名为 的目录4.9,该目录包含gcc-4.9. 同样,我看到一个名为 的软链接5.4.0链接到一个名为 的目录5,该目录包含gcc-5.4. 所以,我希望我想使用prefix=/usr/lib/gcc/5.3而不是使用该--program-suffix选项。这样对吗?

在这一点上,我只是假设当我运行 make & make install 时,.a&.so文件将被放入,/usr/lib/gcc/5.3并且可执行文件最终/usr/bin/gcc-5.3会变成这样,我将能够使用 Ubuntu 的更新替代品在gcc-5.4gcc-5.3gcc-4.9

(注意:我不使用 Synaptic 的原因是它只提供 gcc-5.4,它称之为 gcc-5。同样,ppappa:ubuntu-toolchain-r/test将所有版本的 gcc-5.X 称为 gcc-5,这似乎也很危险使用。我怀疑决定引用 gcc-5.x 的所有次要版本,因为 gcc-5 是我问题的根源)

use*_*262 0

我最终使用的方法是 Ubuntu 的update-alternatives. 请参阅此链接:

安装多个 gcc 版本