how to install gcc 4.9.2 on RHEL 7.4

柔情痞子 提交于 2019-11-26 09:54:54

问题


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.


回答1:


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




回答2:


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



回答3:


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/0B7S255p3kFXNbTBneHgwSzBodFE/view?usp=sharing : 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}


来源:https://stackoverflow.com/questions/47175706/how-to-install-gcc-4-9-2-on-rhel-7-4

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!