LoginSignup
6
7

More than 5 years have passed since last update.

CentOS に GCC 5.2 を Yum でインストールする

Last updated at Posted at 2016-08-28

GCC 4.8.5

gcc --version | head -n1
出力例
gcc (GCC) 4.8.5 20150623 (Red Hat 4.8.5-4)

標準の GCC はバージョンが 4.8 と低い。
残念ながら他のリポジトリーでも GCC のパッケージはないが、 Red Hat Developer Toolset 4.1 を利用することで GCC 5.2 をパッケージでインストールすることが出来る。

Red Hat Developer Toolset 4.1

Red Hat Developer Toolset 4.1 User Guide

インストール

yum install centos-release-scl-rh
yum install devtoolset-4-gcc devtoolset-4-gcc-c++ devtoolset-4-binutils

一時有効化

scl enable devtoolset-4 'bash'

Software Collections なのでそのままではまともに利用できない。

バージョン確認

gcc --version | head -n1
出力例
gcc (GCC) 5.2.1 20150902 (Red Hat 5.2.1-2)

自動有効化設定

cat << _EOF_ > /etc/profile.d/devtoolset-4.sh
#!/bin/bash
source scl_source enable devtoolset-4
_EOF_

scl enable では再ログイン時に再度実行する必要が出てくるため、 /etc/profile.d/ に bash スクリプトを配置することで自動的に有効になるようにすることができる。1

6
7
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
6
7