我正在尝试在Linux上安装gcc和g++ 4.9.2。 我对Linux不太熟悉,看到了一些安装指南,但每次都遇到其他问题。 我的机器上现在没有任何gcc。 我的Linux版本是: Red Hat Enterprise Linux Server release 7.4 (Maipo) 能否有人帮助我提供从头到尾如何正确执行此操作的说明? 非常感谢。
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
安装系统编译器gcc、g++的命令是# yum install gcc-c++
,提供版本4.8.5:/usr/bin/{gcc, g++}
。
其他选项: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 :下载并安装:# cd Downloads/ && yum install ./gcc53-c++-5.3.0-1.el6.x86_64.rpm
..... 提供/usr/bin/{gcc53, g++53}
。
# yum-config-manager --enable rhel-server-rhscl-7-rpms
安装gcc、g++版本4.9.2:# yum install devtoolset-3-gcc-c++
注意:您可以同时安装多个gcc/g++版本(系统编译器是必须的)。
/usr/bin/{gcc49, g++49}
。/usr/bin/{gcc63, g++63}
。/usr/bin/{gcc45, g++45, gfortran45}
gcc42-c++-4.2.4-1.el6.x86_64.rpm https://drive.google.com/file/d/1eYWk6Nd63xeqqAUoJldNWRuwEGO6cAyv/view?usp=sharing → 提供 /usr/bin/{gcc42, g++42}
gcc73-c++-7.3.0-1.el7.x86_64.rpm
https://drive.google.com/file/d/1PgwCP5tu8D0EJbJVTqJd7Vg8dJ4l4noi/view?usp=sharing → 提供 /usr/bin/{gcc73, g++73}
gcc48-c++-4.8.5-1.el6.x86_64.rpm
https://drive.google.com/file/d/1w6fW6oSflDDYZt_cOpGj3QMEmzUC8Q9L/view?usp=sharing → 提供 /usr/bin/{gcc48, g++48, gfortran48}
gcc84-c++-8.4.0-1.el7.x86_64.rpm https://drive.google.com/file/d/1xgFtsiDi2uiB1B0AcOaSpxVizzET-pJf/view?usp=sharing → 提供 /usr/bin/{gcc84, g++84, gfortran84}
gcc84-c++-8.4.0-1.el7.x86_64.rpm
没问题。我会使用它。 - Tung Duong对于CentOS,请运行以下命令:
yum install gcc-c++
RHEL自带预配置的repo,您可以使用yum包管理器搜索所需的软件包并安装。
要这样做,首先运行(以搜索gcc
为例):
$ sudo yum search gcc
这将向您显示一个匹配名称的可用软件包列表。
============================ 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
...
通过运行以下命令安装所需的软件包(例如安装gcc-c++
)
$ sudo yum install gcc-c++
它将安装软件包并要求确认。
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]:
注意:上述步骤将安装可用的最新版本软件包。
yum search gcc-c++
的命令来搜索您想要的软件包,您将获得可用软件包的列表,然后安装并提及正确的名称即可。 - Vipin Yadavscl enable devtoolset-3 bash
加载 GCC 4.9 环境。 - Samir
source scl_source enable devtoolset-3
- hakunami$ scl enable devtoolset-3 bash
https://www.softwarecollections.org/en/scls/rhscl/devtoolset-3/ - Knud Larsendevtoolset-3
已于2016年10月停止支持。如果您需要更新版本的GCC,请在软件集合网站上检查最新的sevtoolset
版本:https://www.softwarecollections.org/en/scls/user/rhscl/?search=devtoolset&policy=&repo=&order_by=-create_date&per_page=10 - shuuji3