how to install gcc 4.9.2 on RHEL 7.4
Asked Answered
P

4

13

I am trying to install gcc and g++ 4.9.2 on Linux. I'm pretty new with Linux and i saw some guides of how to install, but each time I encountered with another problem. I don't have any gcc right now on my machine. my Linux version is: Red Hat Enterprise Linux Server release 7.4 (Maipo) can someone help me and give me instructions from the beginning to the end how to do this properly? thank you very much.

Pelaga answered 8/11, 2017 at 9:16 Comment(0)
S
0

RHEL comes with preconfigured repo, you can search for the desired packages and install them using yum package manager.

To do so, first run ( to search gcc )

$ sudo yum search gcc 

which will show you a list of available packages with the matching name

============================ Name Exactly Matched: gcc =============================
gcc.x86_64 : Various compilers (C, C++, Objective-C, ...)
gcc.x86_64 : Various compilers (C, C++, Objective-C, ...)
gcc.i686 : Various compilers (C, C++, Objective-C, ...)
=========================== Name & Summary Matched: gcc ============================
gcc-c++.x86_64 : C++ support for GCC
gcc-c++.i686 : C++ support for GCC
gcc-gdb-plugin.x86_64 : GCC plugin for GDB
gcc-gdb-plugin.i686 : GCC plugin for GDB
gcc-gdb-plugin.x86_64 : GCC plugin for GDB
gcc-objc.x86_64 : Objective-C support for GCC
...

Install the package you need by running ( to install gcc-c++ )

$ sudo yum install gcc-c++

It will the packages to be installed and ask for confirmation.

Dependencies resolved.
====================================================================================
 Package           Architecture     Version                 Repository         Size
====================================================================================
Installing:
 gcc-c++           x86_64           8.3.1-2.fc29            updates            12 M

Transaction Summary
====================================================================================
Install  1 Package

Total download size: 12 M
Installed size: 29 M
Is this ok [y/N]:

NOTE: Steps mentioned above will install latest available version of the package.


Install a particular Version of a Package
Install all development tools

Spermic answered 8/11, 2017 at 10:4 Comment(7)
thanks, I installed it and it worked but i wanted gcc 4.9.2 but when I checked it (with the command: gcc --vesion) I got: gcc (GCC) 4.8.5 20150623 (Red Hat 4.8.5-16) also I have tried to install g++ in the same way: yum install g++ and this isn't work. how does it work with g++?Pelaga
First search for the package you want by doing for example yum search gcc-c++ you will get a list of available packages, then install the package mentioning the correct name.Spermic
I did the search but I didn't see the version of each compiler. I can see only the names.Pelaga
This link : mirror.centos.org/centos/7/sclo/x86_64/rh ... will show { devtoolset-3/, devtoolset-4/, devtoolset-6/, devtoolset-7/ } links , click a link and look for devtoolset-*-gcc-c++ . But then again : You can use # yum search gcc-c++ to know what's available. ( If you have run # yum-config-manager --enable rhel-server-rhscl-7-rpms )Cyclostome
unix.stackexchange.com/questions/63587/… Check this.Spermic
I finally succeeded installe it. this way: sudo yum install centos-release-scl sudo yum install devtoolset-6 scl enable devtoolset-6 bash So I have gcc 7.2.1 on my machine. But now I have another problem. the old gcc executable file was run over by the new one and now I can't use the previous version of the gcc. Is there a way to solve this?Pelaga
It is better to avoid overriding default gcc compiler on RHEL 7 as other programs compiled using GCC < 4.9 may throw an error with version mismatch for a shared gcc/g++ library. Better approach is one suggested by @Lars-Bilke below. Only caveat being to load GCC 4.9 environment with scl enable devtoolset-3 bash before loading program you compiled using GCC 4.9 library.Myasthenia
S
21
yum install centos-release-scl-rh
yum install devtoolset-3-gcc devtoolset-3-gcc-c++
update-alternatives --install /usr/bin/gcc-4.9 gcc-4.9 /opt/rh/devtoolset-3/root/usr/bin/gcc 10
update-alternatives --install /usr/bin/g++-4.9 g++-4.9 /opt/rh/devtoolset-3/root/usr/bin/g++ 10
Sparteine answered 16/1, 2018 at 11:3 Comment(3)
seems we need to make devtoolset-3 work in bash after install. source scl_source enable devtoolset-3Spermatophyte
@Spermatophyte : $ scl enable devtoolset-3 bash softwarecollections.org/en/scls/rhscl/devtoolset-3Cyclostome
FYI: devtoolset-3 was EOL on Oct 2016. If you need the newer version of GCC, check the latest sevtoolset version in the Software Collections site: softwarecollections.org/en/scls/user/rhscl/…Miles
C
20

For installing the system compilers gcc, g++, the install command is # yum install gcc-c++ → Provides version 4.8.5 : /usr/bin/{ gcc, g++ }.

Other options: 1. gcc53-c++-5.3.0-1.el6.x86_64.rpm → https://drive.google.com/file/d/0B7S255p3kFXNRm9FVnZYUnhyZzg/view?usp=sharing&resourcekey=0-1N6zQa6Sbl_WycG1O9I7JA : Download and install : # cd Downloads/ && yum install ./gcc53-c++-5.3.0-1.el6.x86_64.rpm ..... Provides /usr/bin/{gcc53, g++53}.

  1. The devtoolset´s : https://www.softwarecollections.org/en/scls/rhscl/devtoolset-6/# yum-config-manager --enable rhel-server-rhscl-7-rpms

Install gcc, g++ version 4.9.2 : # yum install devtoolset-3-gcc-c++

Note : You can have as many gcc/g++ versions as you want, installed at the same time. ( The system compilers are a must.)


  1. gcc49-c++-4.9.3-1.el6.x86_64.rpm https://drive.google.com/file/d/1Pwq1ua80dGM72i7rpDNAIIdfcR1WK-hG/view?usp=sharing → Provides /usr/bin/{gcc49, g++49}.

  1. gcc63-c++-6.3.0-1.el7.x86_64.rpm https://drive.google.com/file/d/1t4WrgvpEP-6_NN3qMJhz9MS3CJhHrHKc/view?usp=sharing → Provides /usr/bin/{gcc63, g++63}.

  2. gcc45-c++-4.5.4-1.el7.x86_64.rpm https://drive.google.com/file/d/15aRg-BPhuyaEyZA9Jy-iAyC21_pwN7nD/view?usp=sharing → Provides /usr/bin/{gcc45, g++45, gfortran45}

  3. gcc42-c++-4.2.4-1.el6.x86_64.rpm https://drive.google.com/file/d/1eYWk6Nd63xeqqAUoJldNWRuwEGO6cAyv/view?usp=sharing → Provides /usr/bin/{gcc42, g++42}


  1. gcc73-c++-7.3.0-1.el7.x86_64.rpm https://drive.google.com/file/d/1PgwCP5tu8D0EJbJVTqJd7Vg8dJ4l4noi/view?usp=sharing → Provides /usr/bin/{gcc73, g++73}

  2. gcc48-c++-4.8.5-1.el6.x86_64.rpm https://drive.google.com/file/d/1w6fW6oSflDDYZt_cOpGj3QMEmzUC8Q9L/view?usp=sharing → Provides /usr/bin/{gcc48, g++48, gfortran48}

  3. gcc84-c++-8.4.0-1.el7.x86_64.rpm https://drive.google.com/file/d/1xgFtsiDi2uiB1B0AcOaSpxVizzET-pJf/view?usp=sharing → Provides /usr/bin/{gcc84, g++84, gfortran84}

Cyclostome answered 8/11, 2017 at 21:23 Comment(12)
thank you, your answer is very helpful but I have one more question. if I want to install gcc 6.2 for say, how can I find this particular version of compiler? because you gave me one option to install c++-5.3-1. where do I find other versions to choose?Pelaga
The above devtoolset-6 link : Click CentOS 7 → mirror.centos.org/centos/7/sclo/x86_64/rhdevtoolset -3 -4 -6 -7 : devtoolset-6 has gcc-6.3.1 : # yum install devtoolset-6-gcc-c++ : gcc-6 a.o. will automatically be installed as dependencies. mirror.centos.org/centos/7/sclo/x86_64/rh/devtoolset-6 . ....... About gcc53-c++-5.3.0-1.el6.x86_64.rpm : Provides /usr/bin/{gcc53, g++53}.Cyclostome
@KnudLarsen, your resources are great, but can you provide a step-by-step instruction, how to compile new gcc that will use old libs from standart CentOS 7 installation? Maybe there is some link on such instruction already exists? It will be very helpful.Antimalarial
I'm actually on fedora 31 and I would like to have gcc-8, I tried downloading from pkgs.org but I'm stuck in a dependencies hell, a self contained package like those you linked would really be appreciatedFructuous
@KnudLarsen I have a more formal question here can you write a more detailed answer ?Fructuous
@KnudLarsen I try install gcc/g++ 4.8.5 on centos8.1, However I can't install it. I need one package .rpm for gcc/g++ 4.8.5 on centos8.1. Can you help me? thank youNorford
@KnudLarsen I wan to install gcc/g++ 4.8.5 on Ubuntu 20.04. But Ubuntu 20.04 not support repository for install gcc4.8.5 . Can you help me? If you have guide for build gcc on OS Linux, you can send to me. I will build it. Thank you.Norford
Dear @KnudLarsen , On CentOS7 have package "devtoolset-8". However gcc/g++ in this package is gcc/g++ 8.3.x. - I had used gcc/g++ 8.3.x compile for my project, I got an error "internal compiler error: in type_dependent_expression_p, at cp/pt.c " - However on Ubuntu 18.04, If I use gcc/g++ 8.4.x compile for my project. My project build successful. I guess gcc/g++ 8.3.1 have issue ? Please help me build package rpm gcc/g++ 8.4.x on centos7. Thank you !Norford
Thanks buddy. I built successful with gcc/g++7.3.x. However I want my project build on gcc/g++8. Do you know which version of gcc/g++8 on CentOS doesn't meet the "internal compiler error" like gcc/g++8.4.x on Ubuntu ? @KnudLarsenNorford
Thank you ! Your package at item 9 gcc84-c++-8.4.0-1.el7.x86_64.rpm is ok. I will use it.Norford
Always be careful installing pre-built packages from unknown sources.Telescope
@KnudLarsen, Please, provide the source rpm for packages gcc73-c++-7.3.0-1.el7.x86_64.rpm and gcc84-c++-8.4.0-1.el7.x86_64.rpm. Thank you!Heyday
C
1

For CentOS run this command:

yum install gcc-c++
Colligan answered 19/2, 2023 at 13:9 Comment(0)
S
0

RHEL comes with preconfigured repo, you can search for the desired packages and install them using yum package manager.

To do so, first run ( to search gcc )

$ sudo yum search gcc 

which will show you a list of available packages with the matching name

============================ Name Exactly Matched: gcc =============================
gcc.x86_64 : Various compilers (C, C++, Objective-C, ...)
gcc.x86_64 : Various compilers (C, C++, Objective-C, ...)
gcc.i686 : Various compilers (C, C++, Objective-C, ...)
=========================== Name & Summary Matched: gcc ============================
gcc-c++.x86_64 : C++ support for GCC
gcc-c++.i686 : C++ support for GCC
gcc-gdb-plugin.x86_64 : GCC plugin for GDB
gcc-gdb-plugin.i686 : GCC plugin for GDB
gcc-gdb-plugin.x86_64 : GCC plugin for GDB
gcc-objc.x86_64 : Objective-C support for GCC
...

Install the package you need by running ( to install gcc-c++ )

$ sudo yum install gcc-c++

It will the packages to be installed and ask for confirmation.

Dependencies resolved.
====================================================================================
 Package           Architecture     Version                 Repository         Size
====================================================================================
Installing:
 gcc-c++           x86_64           8.3.1-2.fc29            updates            12 M

Transaction Summary
====================================================================================
Install  1 Package

Total download size: 12 M
Installed size: 29 M
Is this ok [y/N]:

NOTE: Steps mentioned above will install latest available version of the package.


Install a particular Version of a Package
Install all development tools

Spermic answered 8/11, 2017 at 10:4 Comment(7)
thanks, I installed it and it worked but i wanted gcc 4.9.2 but when I checked it (with the command: gcc --vesion) I got: gcc (GCC) 4.8.5 20150623 (Red Hat 4.8.5-16) also I have tried to install g++ in the same way: yum install g++ and this isn't work. how does it work with g++?Pelaga
First search for the package you want by doing for example yum search gcc-c++ you will get a list of available packages, then install the package mentioning the correct name.Spermic
I did the search but I didn't see the version of each compiler. I can see only the names.Pelaga
This link : mirror.centos.org/centos/7/sclo/x86_64/rh ... will show { devtoolset-3/, devtoolset-4/, devtoolset-6/, devtoolset-7/ } links , click a link and look for devtoolset-*-gcc-c++ . But then again : You can use # yum search gcc-c++ to know what's available. ( If you have run # yum-config-manager --enable rhel-server-rhscl-7-rpms )Cyclostome
unix.stackexchange.com/questions/63587/… Check this.Spermic
I finally succeeded installe it. this way: sudo yum install centos-release-scl sudo yum install devtoolset-6 scl enable devtoolset-6 bash So I have gcc 7.2.1 on my machine. But now I have another problem. the old gcc executable file was run over by the new one and now I can't use the previous version of the gcc. Is there a way to solve this?Pelaga
It is better to avoid overriding default gcc compiler on RHEL 7 as other programs compiled using GCC < 4.9 may throw an error with version mismatch for a shared gcc/g++ library. Better approach is one suggested by @Lars-Bilke below. Only caveat being to load GCC 4.9 environment with scl enable devtoolset-3 bash before loading program you compiled using GCC 4.9 library.Myasthenia

© 2022 - 2024 — McMap. All rights reserved.