linux - 如何在 CentOS 上安装 gcc 4.7.3?

标签 linux gcc dockerfile

我想在centos上安装gcc 4.7.3,但是我是这样使用yum search gcc的:

yum search gcc

它显示了太多信息以供选择:

gcc-c++.x86_64 : C++ support for GCC
gcc-gnat.x86_64 : Ada 95 support for GCC
gcc-objc.x86_64 : Objective-C support for GCC
gcc-objc++.x86_64 : Objective-C++ support for GCC
gcc-plugin-devel.x86_64 : Support for compiling GCC plugins
libgcc.i686 : GCC version 4.8 shared support library
libgcc.x86_64 : GCC version 4.8 shared support library
relaxngcc-javadoc.noarch : Javadoc for relaxngcc
compat-gcc-44.x86_64 : Compatibility GNU Compiler Collection
compat-gcc-44-c++.x86_64 : C++ support for compatibility compiler

我不知道gcc 4.7.3是哪个。我想将安装写入 Dokcerfile,请告诉我如何以简单的方式安装它。只需通过终端使用命令 然后,我使用命令:

yum instal gcc-4.7.3

它显示:

Failed to set locale, defaulting to C
Loaded plugins: fastestmirror
base                                                     | 3.6 kB     00:00     
extras                                                   | 3.4 kB     00:00     
updates                                                  | 3.4 kB     00:00     
Loading mirror speeds from cached hostfile
 * base: mirror.neu.edu.cn
 * extras: mirror.neu.edu.cn
 * updates: mirror.neu.edu.cn
No package gcc-4.7.3 available.
Error: Nothing to do

最佳答案

我相信不可能使用 devtools 获得 4.7.3,devtools 包将为您安装 gcc 版本 4.7.2。

devtoolset-1.1 包包含gcc-4.7.2

按照以下命令安装 devtoolset。

cd /etc/yum.repos.d
wget http://people.centos.org/tru/devtools-1.1/devtools-1.1.repo
yum --enablerepo=testing-1.1-devtools-6 install devtoolset-1.1-gcc devtoolset-1.1-gcc-c++

gcc 位于 /opt/centos/devtoolset-1.0/root/usr/bin/ 因此你必须更新 $PATH

export PATH=/opt/centos/devtoolset-1.0/root/usr/bin/:$PATH

现在gcc版本应该是4.7.2版本

您可以使用gcc -v 命令检查它。

注意:您可以选择下载源代码并构建以获取 devtoolset 包中的最新更改。

关于linux - 如何在 CentOS 上安装 gcc 4.7.3?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31633958/

相关文章:

docker - 如何在 Docker 中为 Java 11 设置内存限制?

c++ - 我可以使用 xbuild 在 Linux 上编译 Visual C++ 项目吗?

linux - Bluetooth Low Energy [4.2 及更高版本] - Linux 上 Qt 大于 20 字节的特性

Linux 内核驱动程序 - SPI 如何识别 SPI 设备?

ios - 如何在 iOS 项目中获取预处理器输出?

c - 为 ARMV7A 处理器在用户模式下启用中断

c++ - g++ 版本兼容性

bash - 什么是 |庆典-

linux - 无法访问nginx服务器上的sqlbuddy

azure - 有没有办法更改部署了基于 Linux 的容器的 Azure 应用服务的日期