How do I install gcc-5.3 on Ubuntu 16.04
The approach I ended up using was Ubuntu's update-alternatives
. See this link:
installing-multiple-gcc-versions
Related videos on Youtube
user1245262
Updated on September 18, 2022Comments
-
user1245262 over 1 year
I'm currently running
Ubuntu 16.04
and want to installgcc-5.3
from source, without disrupting thegcc-5.4
andgcc-4.9
that I have already installed using Synaptic package manager.The reason I want
gcc-5.3
is I'm usingCUDA 8.0 RC
, which doesn't support gcc versions after5.3
. Rather than downgrading to4.9
, I'd like to install (or at least know how to install)5.3
. I already have the code forgcc-5.3
and only need to go through theconfigure/make/make install
ritual.Now, I need to understand the various configure options before running make and make install. I particularly want to be certain that I install
gcc-5.3
in the right place and don't interfere with my existinggcc-5.4
andgcc-4.9
.I found one account of how to configure
5.3
, that was as follows:./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
Some of these options make sense, others don't. Specifically, the options I think I understand well enough to not mess myself up are:
--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.
The options that do worry me are:
--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.
When I do a
find . -name gcc
, the only relevant paths I see are/usr/lib/gcc
and/usr/bin/gcc
In
/usr/lib/gcc
, there are two sub-directories -i686-linux-gnu
andx86_64-linux-gnu
, since I have a 64-bit machine, I looked in the x64 directory.There, I saw a soft-link -
4.9.3
, that linked to a directory called4.9
, that had files forgcc-4.9
. Similarly, I saw a softlink called5.4.0
that linked to a directory called5
, that had files forgcc-5.4
. So, I expect that I want to useprefix=/usr/lib/gcc/5.3
and not use the--program-suffix
option. Is this correct?At this point, I'm just assuming that when I run make & make install that the
.a
&.so
files will get placed in/usr/lib/gcc/5.3
and that the executable will end up as/usr/bin/gcc-5.3
and that I'll be able to use Ubuntu's update-alternatives to move amonggcc-5.4
,gcc-5.3
andgcc-4.9
(Note: the reason I'm not using Synaptic is that it only provides gcc-5.4, which it calls gcc-5. Similarly, the ppa
ppa:ubuntu-toolchain-r/test
refers to all versions of gcc-5.X as gcc-5, which also seems dangerous to use. I suspect the decision to refer to all minor versions of gcc-5.x as gcc-5 is the root of my problems)-
0x0C4 over 7 yearsmy strong recommendation is to use docker or LXD container for such different "compiler environments". Makes it much easier to run different compiler setups and versions and you avoid to create a dirty host system.
-
Anwar over 7 yearsI agree with @malo. Especially, I'm against
ppa:ubuntu-toolchain-r/test
. That can cause a lot of headache
-