1

I am new to centos 8 and want to install gcc 6.3.1 on Centos 8 via dnf but it looks like Centos 8 comes with gcc 8.* and no previous version is present in the mirror so downgrading is not working.

Is there a way to install gcc 6.3.1 on Centos 8 from some other repo?

For a relative example of fedora see this thread

1 Answers1

2

You can only downgrade to the version already offered by CentOS 8 and GCC 6.3.1 doesn't fit the bill.

Unfortunately the only way to install this version of GCC without wreaking havoc to your system is to download the source, compile and install it into e.g. /opt/gcc6

As for compile flags check Fedora or CentOS src.rpms - you'll only need to add --prefix=/opt/gcc6

Update: here's how I compiled GCC 4-7:

Unpack it.

(under root/sudo) yum install gcc make glibc-devel gmp-devel mpfr-devel gmp-devel

export CFLAGS="-O2 -march=native -pipe" export CXXFLAGS=$CFLAGS cd gcc-6.3.1 mkdir BUILD cd BUILD

../configure --enable-shared --enable-threads=posix --disable-stage1-checking
--with-system-zlib --enable-__cxa_atexit --enable-multilib --with-gnu-as
--with-gnu-ld --enable-languages="c,c++" --without-x --prefix=/opt/gcc
--disable-libunwind-exceptions --with-gmp=/usr

  • "As for compile flags check Fedora or CentOS src.rpms - you'll only need to add --prefix=/opt/gcc6" Can you please explain this. I am not getting this. Also if you can answer that when i install gcc from koji and install it gives dependences error. how I can install the dependencies automatically via dnf command. – zuri_nahk Aug 25 '20 at 12:54
  • Far more than that is needed. One also has to compile gmp, mpfr, and mpc in that order and then use the --with-mpc, --with-mpfr, and --with-gmp flags as well as setting the environment variable LD_LIBRARY_PATH=/path/to/mpc/lib:/path/to/mpfr/lib:/path/to/gmp/lib. There are also some other flags that might need to be used such as --with-gfortran and --with-quadmath. – Nasir Riley Aug 25 '20 at 12:55
  • @zuri_nahk I've updated the answer with instructions how to compile it. – Artem S. Tashkinov Aug 25 '20 at 14:27
  • @ArtemS.Tashkinov Thanks it looks like this is the only way to go with compiling the source code. I was looking for some simple commands, looks like there isn't. The thing is that I have around 40 packages need to be installed and most of the packages are not in Centos 8 mirror. – zuri_nahk Aug 25 '20 at 14:52
  • All the packages required to compile GCC in CentOS must be within its tree. No 3d party repositories must be necessary. – Artem S. Tashkinov Aug 25 '20 at 15:00
  • You are still missing --with-mpc and --with-mpfr and LD_LIBRARY_PATH. – Nasir Riley Aug 25 '20 at 15:25
  • @NasirRiley 1) Those --with-* are prerequisites 2) In Fedora/RHEL/CentOS they are installed in /usr thus LD_LIBRARY_PATH is redundant. Trust me - that's how I've been building GCC since RedHat 7.0 days. – Artem S. Tashkinov Aug 25 '20 at 15:47
  • @ArtemS.Tashkinov That depends on the version that's being used. RHEL 7 wasn't that long ago and I've been building GCC since CentOS and RHEL 5. The versions of gmp, mpfr, and mpc have to match the version of GCC that's being compiled and it's better to be safe than sorry. If they are redundant, then why do you have --with-gmp? They are also installed in /usr/lib4 and not /usr. – Nasir Riley Aug 25 '20 at 16:29
  • @ArtemS.Tashkinov How we can downgrade glibc on Centos 8 as it is required alongside gcc. If i go for it, i get warning about breakage of some core packages. – zuri_nahk Aug 26 '20 at 06:46
  • I've no idea why a glibc downgrade is required - that's not necessary to compile older versions of GCC – Artem S. Tashkinov Aug 26 '20 at 12:17